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.