Getting permanent access token fails with 'The authorization code was not found or was already used'

jborden13
Shopify Partner
10 0 1

Hello my app retrieves your authorization code and the immediately tries to convert it into a permanent access token.  I'm making a post to:

 

https://{shop}-dev.myshopify.com/admin/oauth/access_token?client_id={API_KEY}&client_secret={API_SEC...

 

from this step:  https://shopify.dev/apps/auth/oauth/getting-started#step-5-get-a-permanent-access-token

 

And it returns an unexpected 'Oops something went wrong' html response with a failed status code 400 error:

 

'Oauth error invalid_request: The authorization code was not found or was already used'

 

What in the world is going on and how can I proceed?  Thank you

Reply 1 (1)

jborden13
Shopify Partner
10 0 1

Just to build on this.  Everything I've found online, leads to the revelation that the context needs to be offline and online context throws this error.  My context has never been online and it's always been offline as evidenced by my call:

 

  const authRoute = await Shopify.Shopify.Auth.beginAuth(
            request,
            response,
            SHOP,
            '/shopify/auth/callback',
            false,
        );
 
And by the returned stated being:
 
state=offline_116xxxx