skip to Main Content

https://help.shopify.com/en/api/getting-started/authentication/oauth

I am using Shopify login for my app and it almost works but I am stuck getting a customer profile from the access token.

https://{shop}.myshopify.com/admin/oauth/access_token

I use this API and now I have access token so how can I get data from that token?

2

Answers


  1. You need to make an API call in below end point in order to get stores basic detail like email domain,currency etc.

    GET /admin/api/2019-10/shop.json
    

    while making a shopiy API call you have to pass accessToken in the request header.
    i.e.

    'headers'  => [
        'Accept'=>'application/json',
        'Content-Type' => 'application/json',
        'X-Shopify-Access-Token'=>$accessToken // access token
    ],
    
    Login or Signup to reply.
  2. There are two types of API you can access in Shopify.

    1. Admin API
    2. Store Front API.

    Admin API

    For Admin API you can create Public App / Private App.

    If you are using Public app then you need to perform oAuth and get AccessToken. And in the each API call you need to pass this accessToken in header as I have suggested in the First Answer.

    If you are using Private App you just need to add APIKey and Secret in the request URL. follow below post for detail.

    shopify how to get product data using php in my localhost

    StoreFront API

    For the store Front API you also can use both public and private APP.

    Let me explain private app first.

    for the private app you need to check Allow this app to access your storefront data using the Storefront API and give appropriate permission to the app. once you set permission and save app. you will get Storefront access token now you can pass this token in each request header to access your store data using storeFront API. and StoreFront API just accessible with graphQL only. see below example how to query storeFront API.

    https://help.shopify.com/en/api/storefront-api/getting-started#storefront-api-authentication

    Now, Public App with StoreFront API

    First you need to perform oAuth and get Store AccessToken. now with passing this accessToken in header and make below request to get your storefront access token.

    POST /admin/api/2019-10/storefront_access_tokens.json
    {
      "storefront_access_token": {
        "title": "Test"
      }
    }
    

    For more detailed version visit here

    In the response you will get storefront access token, now you can add this accessToken in your shopify-javascript-buy-sdk and can make your storeFront API calls.

    Js BuySdk Documentation

    But remember one thing, Storefront API access tokens are not secret. You can place them in a JavaScript file or any public HTML document.And you need to make your public app as sales channel in order to use Store Front API

    Hope this will make sense and will help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search