401 Unauthorized error while creating custom app

Topic summary

Issue: 401 Unauthorized when calling Shopify REST Admin API (Products) from a PHP script for a custom app using basic auth (API key/password embedded in the URL).

Key points:

  • 401 indicates failed authentication; likely due to incorrect credentials, missing permissions, or malformed URL.
  • Advice given: verify API key/password, ensure app has required product read/write scopes, confirm API version (2023-10) and endpoint (/admin/api/2023-10/products.json), and check rate limits and Shopify status. Use cURL with HTTPS and Basic Auth for clearer errors.
  • Technical note: 301 Moved Permanently was later observed, typically a redirect caused by incorrect endpoint, HTTP→HTTPS enforcement, or malformed URL.

Actions/Outcome:

  • Switched to cURL and saw a 301; an image was shared showing the redirect (not essential to resolution).
  • Root cause identified as an error in the URL; correcting it resolved the API access.

Status: Resolved. No remaining open questions or disagreements.

Summarized with AI on January 10. AI used: gpt-5.

Hi,
Thanks for the message.
I tried to replace the code and I get 301 error now

1 Like