Hello, I'm building a react/express app using the shopify apis and I'm looking to use the customer access token to maintain a user's logged in state. I am a graphql novice and have a few questions. My approach would be that when a customer logs in, an access token is created and saved to their localStorage. Upon their return, this token is validated by searching for the customer by customer access token and then updating the state of my app appropriately. The token appears to be valid for (2 weeks?) but I'd like to be able know what the response looks like when said token is expired, without waiting 2 weeks.
So my questions are:
- Are there any examples of responses to the customer query when the token is expired?
- Is the a way to set the expiration of a token so I can test?
- Other than the initial token response when created, is there a way to query for the token expiration on the customer or any other object?
- Is there a gql explorer similar to Shopify GraphiQL App which uses the storefront api as that one only seems to use the admin api? I was not able to find anything from my searching.
Solved! Go to the solution
This is an accepted solution.
1. This will depend on the mutation you are running, but for example, if you attempted to delete the access token and it was expired - you would get access denied
2. The expiry date is set automatically, but you can delete it sooner if you would like with https://shopify.dev/docs/storefront-api/reference/mutation/customeraccesstokendelete
3. no, but you can renew this if needed to be sure before it expires: https://shopify.dev/docs/storefront-api/reference/mutation/customeraccesstokenrenew
You can also set up insomnia for GraphQL - we have a good learning resource here: https://www.shopify.ca/partners/blog/shopify-graphql-learning-kit#configure-insomnia