FROM CACHE - en_header

Consfusion with storeFrontAccessToken

Solved
faroutchris
Tourist
3 1 2

Hello,

I'm just starting out building a custom client storefront. However I'm a bit confused with which token to use and how to acquire the correct one.

I'm using the shopify-buy sdk for javascript.

The config specifies these fields:

const config = {
  storefrontAccessToken: Constants.storefrontAccessToken,
  domain: Constants.storefrontDomain,
};

const client = Client.buildClient(config);

When running a query like client.checkout.create(), I get these errors:

error [Error: The checkoutCreate mutation failed due to an unknown error.]

I think this is due to using the wrong type of token. I have created a custom app in the partner dashboard and copied the key from there. But I suspect this is wrong.

Can I get some pointers on what to do?

Accepted Solution (1)

Accepted Solutions
faroutchris
Tourist
3 1 2

This is an accepted solution.

With a bit of help from _JB I kind of figured it out. Posting here for myself in the future and others who might be confused by the docs.

I had created a custom app in the partner dashboard, this one doesn't give you a storeFrontAccessToken directly, it gives you oauth tokens used for the admin api which can then be further used to obtain the token when the merchant installs the app.

In the store dashboard ([store].myshopify.com/admin), there is an Apps section in the sidebar. Creating an app here gives you a storeFrontAccessToken.

Screenshot 2020-07-15 at 00.43.06.png

View solution in original post

Replies 4 (4)
_JB
Shopify Staff
Shopify Staff
836 99 215

Hey @faroutchris,

If you're using a custom app, Oauth is used to get the storefrontAccessToken. You obtain the token after the merchant approves the Oauth scopes, then you can use the token to access the API, more details are available here.

If you're using the checkoutCreate mutation, make sure you've requested payment processing and asked for the correct Oauth scopes first.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

faroutchris
Tourist
3 1 2

This is an accepted solution.

With a bit of help from _JB I kind of figured it out. Posting here for myself in the future and others who might be confused by the docs.

I had created a custom app in the partner dashboard, this one doesn't give you a storeFrontAccessToken directly, it gives you oauth tokens used for the admin api which can then be further used to obtain the token when the merchant installs the app.

In the store dashboard ([store].myshopify.com/admin), there is an Apps section in the sidebar. Creating an app here gives you a storeFrontAccessToken.

Screenshot 2020-07-15 at 00.43.06.png

Lemondsolutions
New Member
1 0 0

 

Code-Kat
Tourist
3 0 2

Honestly, you are god-sent.  I'm so thankful I can across your post before wasting hours looking for this info. THANK YOU!!!