How to get the store front access token through Shopify API.

Highlighted
Shopify Partner
24 0 0

Hi

Which scope we should use for getting the store front access token?  As per https://help.shopify.com/api/guides/authentication/oauth#scopes

When i try using the scope it shows null value.

Please help me 

 

Regards

 

 

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
618 46 87

Hi there,

There is no scope needed in order to GET a storefront access token. If you're trying to perform a GET request to storefront_access_tokens.json and it is returning null, perhaps you haven't generated any access tokens? If you continue to have trouble, you can include some more info on your request and we can look further.

Cheers,

0 Likes
Highlighted
Shopify Partner
2 0 0

But If I want to post my requests to generate StoreFrontAccess Token, It only returns Error:403

What should I do with it? can anyone help how I do get my StoreFrontAccess Token?

 

Note Its a Public app!

0 Likes
Highlighted
Tourist
9 0 0

I have been searching for this answer. Is there any resolution for getting the storefront-access-token? I have added the required unauthenticated scopes and I have an access token for my app. I am getting 403 using the example code.

 

 

createShopifyAuth({
        apiKey: SHOPIFY_API_KEY,
        secret: SHOPIFY_API_SECRET_KEY,
        scopes: ['read_products''write_products''write_script_tags''unauthenticated_read_product_listings''unauthenticated_write_checkouts''unauthenticated_read_collection_listings'],
        async afterAuth (ctx) {
          const { shopaccessToken } = ctx.session;
       //send request for unauthenticated token here or in page initialization
const storefront_token_response = await fetch(`https://${shopOrigin}/admin/api/2019-10/storefront_access_tokens.json`
  {
    method: "POST",
    headers: new Headers({
      "X-Shopify-Access-Token": accessToken,
      "Content-Type": "application/json"
    }), 
    body: JSON.stringify({
      "storefront_access_token": {
        "title": "customerToken"
      }
    })
  });
  console.log("storefront token"storefront_token_response)
       }
        });
0 Likes
Highlighted
Tourist
9 0 0

Screen Shot 2019-12-16 at 10.53.20 PM.png

0 Likes
Tourist
9 0 0

I have been searching for this answer. Is there any resolution for getting the storefront-access-token? I have added the required unauthenticated scopes and I have an access token for my app. I am getting 403 using the example code.

 

 

createShopifyAuth({
        apiKey: SHOPIFY_API_KEY,
        secret: SHOPIFY_API_SECRET_KEY,
        scopes: ['read_products''write_products''write_script_tags''unauthenticated_read_product_listings''unauthenticated_write_checkouts''unauthenticated_read_collection_listings'],
        async afterAuth (ctx) {
          const { shopaccessToken } = ctx.session;
       //send request for unauthenticated token here or in page initialization
const storefront_token_response = await fetch(`https://${shopOrigin}/admin/api/2019-10/storefront_access_tokens.json`
  {
    method: "POST",
    headers: new Headers({
      "X-Shopify-Access-Token": accessToken,
      "Content-Type": "application/json"
    }), 
    body: JSON.stringify({
      "storefront_access_token": {
        "title": "customerToken"
      }
    })
  });
  console.log("storefront token"storefront_token_response)
       }
        });
0 Likes