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 and refresh 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:
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
|
state | 0.826447872829832 |
- Click the URL above and then the following screen will open:
- Then enter your credentials and grant permissions to COZYROC to access your Shopify Service
- 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 = 2488ddc8ba142504fbb5c891c17c5f1b
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
|
grant_type
| authorization_code ??????
| You should use this value
|
client_id
| d78667e82b03c023965f9235cab24466 | You should use this value
|
redirect_uri
| https%3A%2F%2Fwww.cozyroc.com%2Foauth_callback%2F | You should use this value
|
client_secret
| Em0SYyJ09-NgLvhyT2hPOlfY ??????????
| You should use this value
|
code
| | 2488ddc8ba142504fbb5c891c17c5f1b | | In my case, the Code value will be: 2488ddc8ba142504fbb5c891c17c5f1b. It will be a different value for you. Please look at the information above. |
To create a new POST Request by POSTMAN please follow the steps:
- Login to POSTMAN
- Click the button "New" and select "Request" from the dropdown menu. Please look at the screenshot below:
- Enter request name and save your request.
- Open your request, select POST for the Request and enter for URL: "https://cozyroc-paradise.myshopify.com/admin/api/2019-07". This is the URL where we are going to send the Post Request. Please look at the screenshot below:
- Click "Body"
- Select "x-www-form-urlencoded
- 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 above
- You will also need to set up the Headers as Content-Type = application/x-www-form-urlencoded. Please look at the POSTMAN screenshot below:
- 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 and refresh 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:
If you don't get the response, examine your process for errors and fix them.
We will use the access_token value and the refresh_token values 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
- Go to your REST Connection Manager and click on it twice; the REST Connection Manager configuration screen will open.
- Select "Shopify" for Configuration. Please look at the screenshot below:
- Click the button "New" to create a new token file.
- Complete all the steps until you get to the third page of the Wizard. Please look at the screenshot below:
- For "Access Token", enter the access_token value from the JSON Response you received above.
- For "Refresh Token", enter the refresh_token value from the JSON Response you received above.
- For "Expiration(UTC):", keep the default xpiration date and time value that was automatically calculated(Current UTC date and time + 50 minutes )
- For "Save Files:", enter the file token name and the file path where you want to save the newly generated Token XML File.
- For "Password:", enter a token password. Please look at the screenshot below:
-
- Click the "OK" button. Your token XML file will be generated. Please look at the screenshot below:
- Click the "Test Connection" button and you should get the message "Test connection succeeded".
Book a Presales Call
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 ...
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 ...
How to use a Database storage for new REST tokens
Make sure you have launched Visual Studio as "Run as Administrator". 1 : In Rest Connection Manager choose the configuration from the dropdown list you want to generate token for. 2: For the Token storage parameter in the grid below select Database ...
Considerations when choosing REST token storage
Since version 2.1 in COZYROC SSIS+ access tokens used by REST Connection Manager can be stored not only in the file system, but also in a database (SQL Server). Using such a centralized storage addresses the following complications with the ...
Why does my token keep expiring in a few days?
Issue: Most likely the reason for the token expiration is that the default expiration date of the token has been manually changed in the screen below: Solution: While creating a token the default expiration date should be kept and not changed. The ...