[API] Invalid API key or access token (unrecognized login or wrong password)

jdedea
Shopify Partner
2 0 0

I am trying to access the Shopify Storefront API from my local server and I keep getting the error "[API] Invalid API key or access token (unrecognized login or wrong password)".

 

The error persists when trying to using HTTPie and Postman. Both print back the same result.

 

However, bizarrely enough, the API is working on our live subdomain and is able to make any requests that I want there. I am not sure why it works here but yet all of my local environments say that the code is invalid. 

 

I have validated that the application is still installed, enabled, and all permissions are enabled. I am using the same key in all scenarios. What could possibly be the issue?

Replies 2 (2)

Liam
Shopify Staff
2731 302 783

Hi Jdedea,

 

Is it possible you might be setting the shop_name variable dynamically somewhere based on your env, and then using localhost.myshopify.com/admin/api/2023-04/graphql.json as an endpoint for requests - rather than the actual Shopify store url?

 

Also could you try running the API in curl with verbose mode on, and if the issue persists you can share the x-request-id from the response header? Reviewing the logs might shed more light on this issue.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

jdedea
Shopify Partner
2 0 0

Here is what I got as my response from using cURL in verbose mode:

 

curl: (6) Could not resolve host: POST
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

When I use it without verbose mode, I get:

{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}% 

Hope that helps!