A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am trying to build a simple app, that allows merchants to call an API. In order to do so, I need the merchants API key. I have a text field and a button, and when the button is pressed I want the api key to be saved.
As far as I can tell, the best way to do this, is to use app-owned meta fields.
But in order to save this data, I need my OwnerID. But I cannot find any documentation for how to get this? Hope someone can help me out.
Thanks.
Hey @Potices - the OwnerID is the same number as your app's installation object's ID. To get the installation ID, you can run a simple query like this:
{
app (id:"gid://shopify/App/[insert app ID here]") {
title
installation {
id
}
}
}
This should output the app's installation ID which you can then define as a value in the app-owned metafields call like this:
{
"namespace": "secret_keys",
"key": "api_key",
"type": "single_line_text_field",
"value": "example_value",
"ownerId": "gid://shopify/AppInstallation/[your-app's-installation-id]"
}
]
}
Hope this helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog