How to manually generate a Shopify Token?

How to manually generate a Shopify Token?

A token-based authentication system allows users to enter their username and password in order to obtain a token, which allows them to fetch a specific resource, without using their username and password. Once their token has been obtained, the user can offer the token, which offers access to a specific resource for a time period, to the remote site.  
This article explains how to generate a Shopify Service token, step by step, with the needed permissions for the COZYROC REST Connection Manager component. 
In order to use the generated token, you need to create a specific XML file, which then needs to be entered into the REST Connection Manager Configuration. To simplify this article, the process has been separated into 4 steps:

1) Generate authorization code and give permission to COZYROC to access your Shopify Service
2) Create a custom POST request to be sent to the Shopify server 
3) Receive the authorization token in JSON format so that you can examine the result from the response
4) Create an XML file for the token that complies to the COZYROC token XML format



Step 1: Generate authorization code and give permission to COZYROC to access your Shopify Service

We have prepared a URL for Shopify Service, that is going to be used to grant COZYROC permissions to access your Shopify Service.  Please use the URL below:


You need to replace [shop] with your Shopify's sub-domain.  For example "cozyroc-paradise" is our domain and we are going to use the following URL:


For explanation which parameters you need and the value you need for each parameter please look at the table below. The table below shows the parameters and their value for Shopify token. You will find those parameters and values in the URL above.


Parameters
Value
client_id

d78667e82b03c023965f9235cab24466

redirect_url

https%3A%2F%2Fwww.cozyroc.com%2Foauth_callback%2F
scope
read_content%2Cwrite_content%2Cread_themes%2Cwrite_themes%2C
read_products%2Cwrite_products%2Cread_customers%2Cwrite_customers%2C
read_orders%2Cwrite_orders%2Cread_script_tags%2Cwrite_script_tags%2Cread_fulfillments%2C
write_fulfillments%2Cread_shipping%2Cwrite_shipping%2Cread_analytics
  1. Click the URL above and then the following screen will open:
           
            
  1. Then enter your credentials and grant permissions to COZYROC to access your Shopify Service   
  1. As a result, a link will be generated, that includes the authorization code that we are going to need in Step 2.
          In our case the following link gets generated:
You are going to need the value of the code parameter from the generated URL and, in our case, this value is:
code = 661b34ff9b1e1fe9fb98a16005ba149f
You can use this code for only a single request and it will expire in 5 minutes or less.

Step 2: Create a custom POST request to be sent to the Shopify server

  In this step, we are going to create a POST URL that needs to be sent to the Shopify Server. In order to do that, we will be using POSTMAN. You can use any software that will allow you to do that.

In the following table, you can find all the Post request parameters that you are going to need and their values. 
  

 Parameter
   Value
Notes
 client_id
d78667e82b03c023965f9235cab24466You should use this value
client_secret
5c491dda45ed6293ccba5b810565084cYou should use this value
code
661b34ff9b1e1fe9fb98a16005ba149f
In my case, the Code value will be: 661b34ff9b1e1fe9fb98a16005ba149f. It will be a different value for you. Please look at the information above.
I

To create a new POST Request by POSTMAN please follow the steps:
  1. Login to POSTMAN
  2. Click the button "New" and select "Request" from the dropdown menu.
  3. Enter request name and save your request.
  4. Open your request, select POST for the Request and enter for URL: "https://[shop].myshopify.com/admin/oauth/access_token". This is the URL where we are going to send the Post Request. 
         
 Do not forget to replace [shop] with your Shopify's sub-domain in the URL!

  1. Click "Body" 
  2. Select "x-www-form-urlencoded
  3. Enter for Key and Value all the Post request parameters and their values we showed you in the table above. Please look at the screenshot below:
  4.  
  5. Then click "Send" to send the POST Request
Once you send the Post request you will get a response in JSON format. 

Step 3: You will receive the authorization token in JSON format. You will need to examine the result from the response.
If the operation is successful, you will get a response similar to the following in JSON Format:

{
    "access_token""7f84cfcecc5299da9e2d90fccff9c531",
    "scope""write_content,write_themes,write_products,write_customers,write_orders,write_script_tags,write_fulfillments,write_shipping,read_analytics"
}

If you don't get the response, examine your process for errors and fix them.
We will use the access_token value in the next step to create the XML Token File.

Step 4: Create an XML file for the token that complies with the COZYROC token XML format
  1. Go to your REST Connection Manager and click on it twice; the REST Connection Manager configuration screen will open.
  2. Select  "Shopify"  for Configuration. Please look at the screenshot below:

  3. Click the button "New" to create a new token file.
  4. Complete all the steps until you get to the third page of the Wizard. Please look at the screenshot below:

  5. For "Access Token", enter the access_token value from the JSON Response you received above.
  6. For "Expiration(UTC):", keep the default expiration date and time value that was automatically calculated(Current UTC date and time + 50 minutes ) 
  7. For "Save Files:", enter the file token name and the file path where you want to save the newly generated Token XML File.   
  8. For "Password:", enter a token password. Please look at the screenshot below:
  9.   
  10. Click the "OK" button. Your token XML file will be generated. Please look at the screenshot below:

  11. Click the "Test Connection" button and you should get the message "Test connection succeeded".

    Book a Presales Call

     

    Are you new to COZYROC and evaluating our solutions? 
    Book a Presales Call with us now.

      • Related Articles

      • How to manually generate a Google Services Token?

        A token-based authentication system allows users to enter their username and password in order to obtain a token, which allows them to fetch a specific resource, without using their username and password. Once their token has been obtained, the user ...
      • How to manually generate a Shopify Token?

        A token-based authentication system allows users to enter their username and password in order to obtain a token, which allows them to fetch a specific resource, without using their username and password. Once their token has been obtained, the user ...
      • How to manually generate a Shopify Token?

        A token-based authentication system allows users to enter their username and password in order to obtain a token, which allows them to fetch a specific resource, without using their username and password. Once their token has been obtained, the user ...
      • How to manually generate a Shopify Token?

        A token-based authentication system allows users to enter their username and password in order to obtain a token, which allows them to fetch a specific resource, without using their username and password. Once their token has been obtained, the user ...
      • Where can I find the documentation for the Shopify Connection?

        You can find documentation related to all the COZYROC SSIS+ Component Suite components from the main products page.  Specific documentation for the Shopify Connection can be found at the following link.  For many of the components you can find ...