Home » Php » php – Shopify is giving error 400 [Bad Request] when using https://{shop}.myshopify.com/admin/oauth/access_token

php – Shopify is giving error 400 [Bad Request] when using https://{shop}.myshopify.com/admin/oauth/access_token

Posted by: admin July 12, 2020 Leave a comment

Questions:

I was developing a Shopify App. It was working fine till yesterday evening, but then I started getting the Bad Request [400] error, after the user allow access to the app for his shop.

Error is below

(https://SHOP-NAME.myshopify.com/admin/oauth/access_token) in /path/to/shopify/authentication/oauth.php on line 28
Array (
    [method] => POST
    [uri] => https://SHOP-NAME.myshopify.com/admin/oauth/access_token 
    [query] => Array ( ) 
    [headers] => Array ( ) 
    [payload] => Array ( 
        [client_id] => {CLIENTID} 
        [client_secret] => {CLIENT_SECRET} 
        [code] => {CODE} 
     )
   )

I’m doing a POST cURL Request with Content-Type:application/x-www-form-urlencode and all the request are validated to be coming from shopify.

If anyone want more information I can provide.

Thanks.

How to&Answers:

If this happening after the user authorizes the app, it could be an issue with the permanent token they have received. You could try grabbing the token that is generated and doing a POSTMAN request manually to query the API to verify the token works.

If it worked before and you didn’t make any changes to the app, it could be a temporary API issue, even though I found that to be rare with my app.

Answer:

The code parameter that is sent from Shopify can only be used a single time.

If you re-make the original request that sends the code parameter to your server, you should be able to make the call successfully.