'App must have a channel record to create a storefront access token.

Highlighted
Excursionist
38 3 2

I tried to fix this error by converting the app to a sales channel. The error remains. What needs to be done to create a "channel record" ? Google isn't turning anything up on that topic?

 

I encounter this error while attempting to connect to the StoreFrontAccessToken API:

 

const returnStoreFrontToken = async (generalAccessToken, shopHost) => {
 const storeFrontAccessTokenUrl = `https://${shopHost}/admin/api/2019-10/storefront_access_tokens.json`;
 
 // get a list of current storefront access tokens
 try {
  const getResponse = await fetch(storeFrontAccessTokenUrl, {
   method : "get"
   , headers : {
    "X-Shopify-Access-Token" : generalAccessToken
   }
  });
  const data = await getResponse.json();
  console.log(data, `=====data after get token(s)=====`);
  }
 } catch (e) {
  console.log(e, `=====error=====`);
 }
};

//
app.use(async ctx => {
  const {shop, accessToken} = ctx.session;
  console.log(`=====inside the middleware after verifyRequest()=====`);
  
  const returnedToken = await returnStoreFrontToken(accessToken, shop); // 'App must have a channel record to create a storefront access token.
0 Likes
Shopify Staff
Shopify Staff
139 23 28

Hi @seandz ,

 

This error of "App must have a channel record to create a storefront access token" is thrown by Shopify in the case when the API Client ID of the Sales Channel who is requesting the new Storefront Access Token is not present at all for the Shopify store that the Storefront Access Token is being generated for. In other words, this error message will be thrown if your Sales Channel is not installed currently on your Shopify store.

 

If this Sales Channel is indeed installed on your Shopify store and you are still getting this error, could you please provide the value of the "X-Request-ID" header in the error response from Shopify? With this value we can go through our platform logs and investigate more as to why this error is occurring.  If you cannot get this value, then providing the Shopify store ID/Name and the approximate time the error occurred will also help as well

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Excursionist
38 3 2

Thanks @hassain , the app clearly shows as a Sales Channel so that is not the issue. Please check seandezoysa.myshopify.com for requests today and yesterday and you will see the errors in your logs.

0 Likes
Shopify Staff
Shopify Staff
139 23 28

Hi @seandz ,

 

After investigating into this I have found for some reason even though I can verify that your Sales Channel is installed on your store and I can see the Sales Channel in your Shopify admin on the left hand side of the screen, there is still no record in our databases of your Sales Channel being active for your store. This might happen if your app was upgraded to a Sales Channel after the app was initially installed to the shop, or if the Sales Channel has no products available for it. Could you perhaps try uninstalling and then re-installing the Sales Channel to your Shopify store, and/or adding products to your Sales Channel, and then try to see if this corrects the error you are seeing?

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Excursionist
38 3 2

Thank you @hassain. I'm seeing this now:

 

export const returnStoreFrontToken = async (generalAccessToken: string, shopHost: string) => {
 const storeFrontAccessTokenUrl = `https://${shopHost}/admin/api/2019-10/storefront_access_tokens.json`;
 
 // get a list of current storefront access tokens
 try {
  const getResponse = await fetch(storeFrontAccessTokenUrl, {
   method : "get"
   , headers : {
    "X-Shopify-Access-Token" : generalAccessToken
   }
  });
  const data = await getResponse.json();
  console.log(data, `=====data after get token(s)=====`); // { errors: 'Token must be service access.' }
};

 

What does this mean? I am passing the OAuth token in as you can see below. I removed code above which would attempt to post/create a token if it found none from the get request, but as the get request is having trouble I'm now asking about that.

 

 

// server setup
app
// sets up secure session data on each request
 .use(session(app))
 
 // sets up shopify auth
 .use(
  shopifyAuth({
   apiKey: API_KEY,
   secret: API_SECRET,
   scopes: ['read_products', "read_inventory", 'read_script_tags', 'write_script_tags', 'unauthenticated_read_product_listings'],
   afterAuth(ctx) {
    ctx.redirect('/');
   },
  }),
 )

 .use(verifyRequest())
 
 // application code
 .use(async ctx => {
  console.log(`=====inside the middleware after verifyRequest()=====`);
 
  if (ctx.session === null) {
   console.log(`====ctx.session missing======`);
   return;
  }
  
  const {shop, accessToken} = ctx.session;
  
  const sFToken = await returnStoreFrontToken(accessToken, shop);
  // continues
0 Likes
Shopify Staff
Shopify Staff
139 23 28

Hey @seandz ,

 

As per this thread, there are three reasons why you might see the "Token must be service access" error:

 

1. Your access token is a per-user online access token

2. Your access token is a delegate access token

3. There is a unexpired refresh token that exists

 

From our internal dashboards I can see that your app is not set-up for per-user online access tokens, so the issue is most likely stemmed from 2 or 3. 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Excursionist
38 3 2

Hi @hassain , 

 

I did not make any delegate token requests so we can eliminate that option. That leaves only the refresh token concern. I see this in the docs:

 

Many of the access tokens stored by your app will be associated with the old secret key. New access tokens must be requested from the Shopify API to work with the new secret key

I took a look at the API Secret Key. It is the same as it has been. Which also means a new refresh token is not needed.

 

Could there be any other reason this is happening?

0 Likes