401 Unauthorized: Oauth Access tokens Issue

Highlighted
New Member
3 0 0

Hi Team,

I was able to grab the access token until 02-19-2019 and then suddenly all my requests started getting 401 unauthorized

Here is the request, added request ID to give me more insights. 

 

Error: The authorization code was not found or was already used

 

curl -X POST \
https://perfect-audience-test-store.myshopify.com/admin/oauth/access_token \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 62d13228-7640-4694-8ec4-e2e237d0d800' \
-H 'cache-control: no-cache' \
-d '{
"code": "bf16608b95775849d32e561021cf0612",
"client_secret": "xxx",
"client_id": "xxx"
}'

Response: 401 Unauthorized

X-Request-Id →00f37786-2df9-4136-9e37-c2fafadc8c8b
0 Likes
Shopify Staff
Shopify Staff
299 32 59

Hey there,

 

I've taken a look at the request id you've provided and I see that we're returning a 400 error for your POST request to the access token endpoint.

 

The code parameter which is returned during the installation flow, can only be exchanged once for an access token. 

 

Are you using the code parameter from the most recent installation, and are you sure that code parameter hasn't already been exchanged for an access token?

0 Likes
New Member
3 0 0

Hi Zameer,

Yes we are making that request only once to retrieve the access token. Can you see from the logs on your end, if you see any duplicate requests. We are sure that we are making only 1 request.

 

Thanks 

0 Likes
Shopify Staff
Shopify Staff
299 32 59

Unfortunately, I'm unable to determine that from our logs, as we don't store code parameters for security purposes.

 

I do see however, that there have been requests made in the last 24 hours that have completed successfully. These requests are followed by other requests to the same end point which have resulted in 400's.

 

In the example you provided, I see the code parameter is hard coded. Are you dynamically retrieving this value from the installation redirect?

0 Likes
New Member
3 0 0

Yes we are retrieving it from the redirect URL the code value

?code=d21bdbd2e7c9f07748f95c7141abcdac&hmac=ba8fd3881ea5e93a92b81e5e5edde9e46e9e7bb77844451d48641a0895870c99&shop=perfect-audience-test-store.myshopify.com&timestamp=1550809169

It was working until Feb 19/20 and then is stopped suddenly, throwing 401. 

Any other means where we can look into debugging, would  be appreciated ?

 

Thanks Again

0 Likes