TDV Adapter for Shopify

Build 22.0.8462

Basic Tab

Connecting to Shopify

In all cases, you must set ShopUrl to the full URL of your Shopify shop (https://yourshopname.myshopify.com). The rest of this document assumes that you have done so.

Access Token

Create a Custom App

Before authenticating, you need to create a custom application via your Shopify admin page. Follow the steps below to register an application and obtain the access token:

  1. Log in to your Shopify from the admin page and navigate to Apps > Apps and sales channels.
  2. Click Develop apps and select Create an app.
  3. In the Overview tab, click Configure Admin API scopes and select the access permissions for your store that you want to grant to your application. The permissions required by our provider to use all the tables and views are:
    • read_assigned_fulfillment_orders, write_assigned_fulfillment_orders
    • read_content, write_content
    • read_customers, write_customers
    • read_draft_orders, write_draft_orders
    • read_fulfillments, write_fulfillments
    • read_gift_cards, write_gift_cards
    • read_inventory, write_inventory
    • read_marketing_events, write_marketing_events
    • read_orders, write_orders
    • read_price_rules, write_price_rules
    • read_product_listings, write_product_listings
    • read_products, write_products
    • read_reports, write_reports
    • read_script_tags, write_script_tags
    • read_shopify_payments_payouts
    • read_themes, write_themes
  4. Click Save.
  5. Select API Credentials.
  6. Under "Access tokens" click Install app. This creates your access token.
  7. Copy your access token under Admin API Access token. NOTE: The token can be revealed and copied only once.

Access Token

To authenticate using an access token, specify the following:

  • AuthScheme: Set to AccessToken.
  • AccessToken: Set to the access token value you copied from the custom app.

OAuth

To connect using OAuth, you must create a public or custom application in the Shopify Partner Dashboard. During this process, API key and API secret key values are generated. You need these keys when you connect using a custom application. See Creating a Custom OAuth App for the procedure.

Note: You must set AuthScheme to OAuth. All the sections below assume that you have done so. Otherwise, you cannot connect.

Desktop Authentication

You must create a custom application and specify Client Id and Client Secret properties.

After setting the following, you are ready to connect:

  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property.
  • OAuthClientId: Set this to the app's API key value.
  • OAuthClientSecret: Set this to the app's API secret key value.
  • CallbackURL: Set this to the redirect URI defined when you registered your app.
When you connect, the adapter opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The adapter then completes the OAuth process by saving OAuth values in OAuthSettingsLocation that persists across connections and obtaining a new access token when the old one expires.

Headless Machines

To create Shopify data sources on headless servers or other machines on which the adapter cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.

  1. Instead of installing the adapter on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the adapter on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
  2. You can then configure the adapter to automatically refresh the access token from the headless machine.
You can follow the headless OAuth authentication flow using the OAuth credentials for your custom OAuth app.

Create a Custom OAuth App

See Creating a Custom OAuth App for the procedure. You can then follow the steps below to authenticate and connect to data.

Obtain a Verifier Code

Set the following properties on the headless machine:

  • InitiateOAuth: Set this to OFF.
  • OAuthClientId: Set this to the API key.
  • OAuthClientSecret: Set this to the API secret key.

You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.

  1. Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
  2. Open the returned URL in a browser. Log in and grant permissions to the adapter. You are then redirected to the callback URL, which contains the verifier code.
  3. Save the value of the verifier code. You will set this in the OAuthVerifier connection property.

On the headless machine, set the following connection properties to obtain the OAuth authentication values:

  • OAuthClientId: Set this to the API key.
  • OAuthClientSecret: Set this to the API secret key.
  • OAuthVerifier: Set this to the verifier code.
  • OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
  • InitiateOAuth: Set this to REFRESH.

After the OAuth settings file is generated, set the following properties to connect to data:

  • OAuthClientId: Set this to the API key.
  • OAuthClientSecret: Set this to the API secret key.
  • OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the adapter to enable the automatic refreshing of the access token.
  • InitiateOAuth: Set this to REFRESH.

Transfer OAuth Settings

Follow the steps below to install the adapter on another machine, authenticate, and then transfer the resulting OAuth values.

On a second machine, install the adapter and connect with the following properties set:

  • OAuthSettingsLocation: Set this to the path of a writable text file.
  • InitiateOAuth: Set this to GETANDREFRESH.
  • OAuthClientId:Set this to the app's API key value.
  • OAuthClientSecret: Set this to the app's API secret key value.
  • CallbackURL: Set this to the Redirect URI you specified in your app settings.

Test the connection to authenticate. The resulting authentication values are encryped and writtento the path specified by OAuthSettingsLocation. After you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:

  • InitiateOAuth: Set this to REFRESH.
  • OAuthClientId: Set this to the app's API key value.
  • OAuthClientSecret: Set this to the app's API secret key value.
  • OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the adapter to enable the automatic refreshing of the access token.

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462