ODBC Driver for Shopify

Build 22.0.8462

Linux DSN Configuration

This section describes how to set up ODBC connectivity and configure DSNs on several Linux distributions: Debian-based systems, like Ubuntu, and Red Hat Linux platforms, like Red Hat Enterprise Linux (RHEL), CentOS, and Fedora.

Minimum Linux Versions

Here are the minimum supported versions for Red Hat-based and Debian-based systems:

OSMin. Version
Ubuntu11.04
Debian7
RHEL6.9
CentOS6.9
Fedora13
SUSE12.1

Installing the Driver Dependencies

Run the following commands as root or with sudo to install the necessary dependencies:

  • Debian/Ubuntu:
    apt-get install libc6 libstdc++6 zlib1g libgcc1
  • RHEL/CentOS/Fedora:
    yum install glibc libstdc++ zlib libgcc

Here are the corresponding libraries required by the driver:

Debian/Ubuntu PackageRHEL/CentOS/Fedora PackageFile
libc6glibclinux-vdso.1
libc6glibclibm.so.6
libc6glibclibrt.so.1
libc6glibclibdl.so.2
libc6glibclibpthread.so.0
libc6glibclibc.so.6
libc6glibcld-linux-x86-64.so.2
libstdc++6libstdc++libstdc++.so.6
zlib1gzliblibz.so.1
libgcc1libgcclibgcc_s.so.1

Installing the Driver

You can use standard package management systems to install the driver.

On Debian-based systems, like Ubuntu, run the following command with root or sudo:

dpkg -i /path/to/driver/setup/ShopifyODBCDriverforUnix.deb 

On systems that support the RPM package format, run the following command with root or sudo:

rpm -ivh /path/to/driver/ShopifyODBCDriverforUnix.rpm 

Licensing the Driver

Run the following commands to license the driver. To activate a trial, omit the <key> input.

cd /opt/cdata/cdata-odbc-driver-for-shopify/bin/
sudo ./install-license.sh <key>

Connecting through the Driver Manager

The driver manager loads the driver and passes function calls from the application to the driver. You need to register the driver with the driver manager and you define DSNs in the driver manager's configuration files.

The driver installation registers the driver with the unixODBC driver manager and creates a system DSN. The unixODBC driver manager can be used from Python and from many other applications. Your application may embed another driver manager.

Creating the DSN

See Using unixODBC to install unixODBC and configure DSNs. See Using the DataDirect Driver Manager to create a DSN to connect to OBIEE, Informatica, and SAS.

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 driver opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The driver 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 driver cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.

  1. Instead of installing the driver on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the driver on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
  2. You can then configure the driver 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.

Note that the headless OAuth flow uses several undocumented connection properties -- you can set these in the connection string as usual.

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 driver. 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 driver to enable the automatic refreshing of the access token.
  • InitiateOAuth: Set this to REFRESH.

Transfer OAuth Settings

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

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

  • OAuthSettingsLocation: Set this to the path of a writable text file.
  • 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 driver to enable the automatic refreshing of the access token.

Set the Driver Encoding

The ODBC drivers need to specify which encoding to use with the ODBC Driver Manager. By default, the CData ODBC Drivers for Unix are configured to use UTF-16 which is compatible with unixODBC, but other Driver Managers may require alternative encoding.

Alternatively, if you are using the ODBC driver from an application that uses the ANSI ODBC API it may be necessary to set the ANSI code page. For example, to import Japanese characters in an ANSI application, you can specify the code page in the config file '/opt/cdata/cdata-odbc-driver-for-shopify/lib/cdata.odbc.shopify.ini':

[Driver]
AnsiCodePage = 932

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