iOS Buy SDK just replies `401` - unauthorized to all queries

Topic summary

Issue Identified:
A developer encountered persistent 401 (unauthorized) errors when using the iOS Buy SDK with a custom Shopify app. They had created a custom app with Admin API access and used the API key from the credentials page, but all mobile queries failed despite the Admin API access token working via curl.

Root Cause:
The problem stemmed from selecting the wrong API type during custom app creation. The developer initially chose “Admin Access API” when they should have selected “StoreFront API” for mobile SDK integration.

Additional Confusion:

  • Uncertainty about which credential to use: the Admin API access token (a non-hex string) versus the API key (a 32-character hex string)
  • Documentation references an example API key format that didn’t match available credentials
  • Product availability settings mentioned in docs couldn’t be found—only a “Sales Channels” selector appeared under Publishing, without the custom app listed

Resolution:
Creating a new custom app with “StoreFront API access” instead of “Admin Access API” resolved the authorization errors. The iOS Buy SDK requires StoreFront API credentials, not Admin API credentials.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

Hey there,

when I try the below code to make a basic query for the Shops name and description, I always just get a 401 response.
In the shopify admin under the Apps and sales channel page, I went to App development, created a custom app, gave it scope and then copied the API key from the API Credentials.

I tested the Admin API access token using curl to get [https://{my](https://{my) store}.myshopify.com/admin/api/2024-04/products.json which worked.
But if I try to use the API Key from lower on that page in the mobile app, all I ever get are 401 errors.

On the page https://shopify.dev/docs/custom-storefronts/mobile-apps/buy-sdk-ios (iOS Buy SDK), it does say:
After you've generated an access token,
does that mean we should put the Admin API Access token into the mobile App? Because anyone could extract it from their phone and read it from the app bundle, so the only thing I can imagine is this semi-public API key in the bottom of Custom App - API credentials page.
What also stumps me is that on the github README, the example code uses an apiKey of `

apiKey:     "dGhpcyBpcyBhIHByaXZhdGUgYXBpIGtleQ",

which is not a hex string, while the API key on the page https://admin.shopify.com/store/{store}/settings/apps/development/{app id}/api_credentials
is clearly a 32-character hex string/

Here’s the code I used for testing:

        client = Graph.Client(
            shopDomain: {storename}.myshopify.com,
            apiKey: apiKey
        )

        let query = Storefront.buildQuery { $0
            .shop { $0
                .name()
                .description()
            }
        }
        let task = client.queryGraphWith(query) { response, error in
            if let response = response {
                log.debug("Response: \(response)")
                let name = response.shop.name
            } else {
                log.error("Query failed: \(String(describing: error))")
            }
        }
        task.resume()

Another thing that worries me, the docs say:

Make a product availableAnchor link to section titled “Make a product available”> 1. From your Shopify admin, go to Products.> 1. From the Products page, click the product you want to make available.> 1. Next to SALES CHANNELS AND APPS click Manage.> 1. In the Sales channels and apps dialog box, select the box next to the name of your custom app.

The Problem is that on the product page, under **Publishing** there is only a Sales channels selector.
I can click on the three dots menu to open “Manage Sales Channels” with a bunch of options next to checkboxes, but none of the options have the name of the custom app I have created under the Settings → Apps and sales channels → Develop apps

Ok, it seems I solved this problem.

When first creating the custom app, one has to choose between Admin Access API and StoreFront Api.

Our first attempt had the former, we should have chosen the latter.

I created a new custom app with StoreFront API access and that works.