A quick article showing 2 ways of connecting to Shopify's REST API with a custom app.
Note that this is not for an app embedded in the Shopify instance but for a third-party app, such as a Zoho Creator app, to connect to the data within Shopify.
Why?
At time of print, we have woken up to the news that including a username and password, or a client and secret in the endpoint of a URL will no longer be supported in the Zoho Deluge invokeURL task...
This article exists because I spent 2 hours going down the rabbit hole of trying to use OAuth2 and following the usual steps: Grant Code, Refresh Token, Access Token. I also went down the rabbit hole of installing app-bridge and configuring a JWT which was an absolute waste of time with regards to what I was attempting to do.
How?
Let me show you how we used to connect and then what the new code will be. The preamble to both of these is how to get the values to include in the invokeURL headers and payload.
Previously on...
copyraw
m_Header = Map(); m_Header.put("Content-Type","application/json"); // // app specific (retrieving from a ZohoCreator record that stores all these credentials) r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"]; // // client id from the shopify admin and registering a custom app // eg. 00112233445566778899aabbccddeeff v_ClientID = r_ShopifyAPI.Client_ID; // // client secret from the shopify admin and registering a custom app // eg. shpss_aaabbbcccdddeeefff01234567890 v_ClientSecret = r_ShopifyAPI.Client_Secret; // // the shop id from the URL https://{shop_id}.myshopify.com // eg. my-example-store v_ShopID = r_ShopifyAPI.Shop_ID; // // concatenated for the endpoint v_ShopifyURL = "https://" + v_ClientID + ":" + v_ClientSecret + "@" + v_ShopID + ".myshopify.com"; // // per endpoint request to specify which API version (eg. 2025-07) v_ShopifyApiVersion = r_ShopifyAPI.API_Version; // // url with client id and client secret (now to be deprecated July 25, 2025 by Zoho) // where p_OrderID is the shopify order ID v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion + "/orders/" + p_OrderID + ".json"; r_GetOrder = invokeurl [ url :v_Endpoint type :GET headers:m_Header ]; info r_GetOrder;
- m_Header = Map();
- m_Header.put("Content-Type","application/json");
- //
- // app specific (retrieving from a ZohoCreator record that stores all these credentials)
- r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"];
- //
- // client id from the shopify admin and registering a custom app
- // eg. 00112233445566778899aabbccddeeff
- v_ClientID = r_ShopifyAPI.Client_ID;
- //
- // client secret from the shopify admin and registering a custom app
- // eg. shpss_aaabbbcccdddeeefff01234567890
- v_ClientSecret = r_ShopifyAPI.Client_Secret;
- //
- // the shop id from the URL https://{shop_id}.myshopify.com
- // eg. my-example-store
- v_ShopID = r_ShopifyAPI.Shop_ID;
- //
- // concatenated for the endpoint
- v_ShopifyURL = "https://" + v_ClientID + ":" + v_ClientSecret + "@" + v_ShopID + ".myshopify.com";
- //
- // per endpoint request to specify which API version (eg. 2025-07)
- v_ShopifyApiVersion = r_ShopifyAPI.API_Version;
- //
- // url with client id and client secret (now to be deprecated July 25, 2025 by Zoho)
- // where p_OrderID is the shopify order ID
- v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion + "/orders/" + p_OrderID + ".json";
- r_GetOrder = invokeUrl
- [
- url :v_Endpoint
- type :GET
- headers:m_Header
- ];
- info r_GetOrder;
Now Continuing...
Using the API Admin Access Token:
copyraw
r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"]; v_ClientID = r_ShopifyAPI.Client_ID; v_ClientSecret = r_ShopifyAPI.Client_Secret; v_ShopifyApiVersion = r_ShopifyAPI.API_Version; v_Shopify_BaseURL = "https://" + v_ShopID + ".myshopify.com"; // m_Header = Map(); m_Header.put("Content-Type","application/json"); // The access token is the Admin API token received when installing the custom app for the first time m_Header.put("X-Shopify-Access-Token",r_ShopifyAPI.Access_Token.trim()); // v_Endpoint = v_Shopify_BaseURL + "/admin/api/" + v_ShopifyApiVersion + "/orders/" + p_OrderID + ".json"; r_GetOrder = invokeurl [ url :v_Endpoint type :GET headers:m_Header ]; info r_GetOrder;
- r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"];
- v_ClientID = r_ShopifyAPI.Client_ID;
- v_ClientSecret = r_ShopifyAPI.Client_Secret;
- v_ShopifyApiVersion = r_ShopifyAPI.API_Version;
- v_Shopify_BaseURL = "https://" + v_ShopID + ".myshopify.com";
- //
- m_Header = Map();
- m_Header.put("Content-Type","application/json");
- // The access token is the Admin API token received when installing the custom app for the first time
- m_Header.put("X-Shopify-Access-Token",r_ShopifyAPI.Access_Token.trim());
- //
- v_Endpoint = v_Shopify_BaseURL + "/admin/api/" + v_ShopifyApiVersion + "/orders/" + p_OrderID + ".json";
- r_GetOrder = invokeUrl
- [
- url :v_Endpoint
- type :GET
- headers:m_Header
- ];
- info r_GetOrder;
Category: Zoho :: Article: 907
Add comment