Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

POST request to https://{shopifyShopOrigin}/admin/api/2019-10/graphql.json returns a 401 Unauthorize

POST request to https://{shopifyShopOrigin}/admin/api/2019-10/graphql.json returns a 401 Unauthorize

CommerceOwl
Shopify Partner
9 1 1

Hi folks,

I've got an interesting problem. For some reason it doesn't happen to me but to the app review team.

I'm using offline access tokens and initially make a call to get basic shop data like so:

const accessTokenUrl = `https://${shop}/admin/api/2020-04/shop.json?access_token=${accessToken}`;
const shopInfo = await Axios.get(accessTokenUrl);

That works fine.

However, a little later we do a request against https://{shopifyShopOrigin}/admin/api/2019-10/graphql.json and the result is a 401 Unauthorized:

 

const data = JSON.stringify({
  query: `mutation {
      appSubscriptionCreate(...)     
    }`,
});

const response = await fetch(
      `https://${store.shopifyShopOrigin}/admin/api/2019-10/graphql.json`,

      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'X-Shopify-Access-Token': store.shopifyAccessToken,
        },
        body: data,
      },
    );

const responseJson = await response.json();

 

What makes this especially strange is that I cannot reproduce it with my test development shops.

Any ideas on how to track this down or where to start looking?

Sell more with recipes at. Learn more at commerceowl.com
Reply 1 (1)

BoxUp
Shopify Partner
38 1 15

Hey,

Have you tried a newer API version for your graphql.json request? I notice it's using 2019-10 at the moment.

This page says it's no longer supported as of 6 days ago.