Auth0 Home Blog Docs

Using Auth0 Social Connect with Shopify : Oauth error invalid_request:found

shopify

#1

I am trying to do social connect with Shopify to get access token for accessing shopify api, I been followed the steps as per the auth0 document https://auth0.com/docs/connections/social/shopify and I got success response as per the document

also got access code in redirect url, if use this code to get access token to shopify using postman it show following error: Oauth error invalid_request: The authorization code was not found or was already used

If any suggestion or steps to do further that appreciated


#3

:wave: @Manikandan are you using the code again in Postman? We should only be using the OAuth code parameter once. It sounds like the code may be reused but it can only be used a single time to get the access token. And then once we have the access token we can use that to make requests to Shopify API.


#4

Hi @kim.noel I am not using code again in Postman, after the redirection screen I just copy the code value into postman and tried to request for authorise token so I using this code only once, are your saying just copy and pasting the code value into postman it will consider to be reusing of this value?


#5

I think there may be some confusion, we can get the IdP (in this case Shopify) access token by following the steps outlined in here:

Everything described here (which I believe is what you were refering to when you mentioned a code) is handled. That is why when you try to use that code to get an access token, it has already been consumed and generated an access token for us.

En example of the access token busy accessed in a Rule would look something like the following:

function (user, context, callback) {

     const shopifyIdentity = user.identities.filter(function (identity) { 
         return identity.connection === 'shopify';
     })[0];

     // The user hasn't logged using Shopify so skip 
     if (!shopifyIdentity){ 
         return callback(null, user, context);
     }

     const accessToken = shopifyIdentity.access_token;

   // do things here ... 

     // when done call back the app
     callback(null, user, context);
}

another way is to get the access token through the [Auth0 Management API v2](- https://auth0.com/docs/api/management/v2) - outlined here.