skip to Main Content

I am trying to fetch customer information from my Shopify store using the REST API and GraphQL API, but I keep encountering errors related to access permissions and authentication.

I am using a headless app to interact with the Shopify API. Here’s the setup I’m using:

  1. REST API Request: I attempted to retrieve customer information using the following GET request:

GET https://[STORE-ID].myshopify.com/admin/api/2023-01/customers/8696123785497.json

With the following headers:

-H "X-Shopify-Access-Token: [YOUR_ACCESS_TOKEN]" -H "Content-Type: application/json"

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

  1. GraphQL API Request: I also tried to create a customer using the GraphQL API with this request:

POST https://[STORE-ID].myshopify.com/admin/api/2024-10/graphql.json

Error Response:

{ "message": "Access denied for customerCreate field. Required access: write_customers access scope." }

Any help or guidance would be greatly appreciated!

Steps Taken:

  • I have confirmed that the access token I am using is correct.
  • I checked the permissions in my Shopify Partner Dashboard and ensured that the necessary scopes (read_customers and write_customers) are enabled for my app.

2

Answers


  1. Please check the API scope: it should be read_customers and write_customers scopes if any doubt then reinstall the app. Also, check the API version in your requests (2023-01 for REST and 2024-10 for GraphQL)

    Login or Signup to reply.
  2. If your app is created via shopify admin then please confirm scopes in shopify admin -> settings -> Apps and sales channels. Click on ‘Develop Apps’ and select your app and then check Configurations.

    Please make sure you have selected correct permissions. (read_customers, write_customers)

    If your app is created via partners account then you need to add scopes in your app URL (Which is added in App configuration is app settings).
    For example: if your app authentication file is created in PHP then scope will add like:

    // Set variables for our request
    $shop = "shop-name";
    $api_key = "shopify-api-key";
    $scopes = "read_customers, write_customers";
    $redirect_uri = "Your-Redirect-URL";
    
    // Build install/approval URL to redirect to
    $install_url = "https://" . $shop . ".myshopify.com/admin/oauth/authorize?client_id=" . $api_key . "&scope=" . $scopes . "&redirect_uri=" . urlencode($redirect_uri);
    
    // Redirect
    header("Location: " . $install_url);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search