ODBC Driver for WordPress

Build 25.0.9434

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) and Fedora.

Minimum Linux Versions

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

OSMin. Version
Ubuntu18.04
Debian10
RHEL8
Fedora28
SUSE15

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/Fedora:
    yum install glibc libstdc++ zlib libgcc

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/WordpressODBCDriverforUnix.deb 

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

rpm -ivh /path/to/driver/WordpressODBCDriverforUnix.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-wordpress/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 WordPress

CData ODBC Driver for WordPress supports connecting to self-hosted WordPress instances and WordPress Online instances.

  • If you are connecting to self-hosted WordPress, you must provide the URL of your WordPress site and then authenticate.
  • If you are connecting to WordPress Online, you can choose between OAuth 2.0 and OAuth Password authentication.

Connecting to Self-Hosted WordPress

For self-hosted WordPress instances, to connect to data, provide the full URL for your WordPress site, and then authenticate as described below. For example, if your site is hosted at http://localhost/wp/wordpress, you should enter it as http://localhost/wp/wordpress, not just http://localhost. Failing to provide the complete URL will lead to a 'site not found' error.

Self-hosted WordPress instances support two types of authentication:

  • Basic authentication: This method is recommended for use in testing environments. It provides a way to access your WordPress instance.
  • OAuth 2.0 authentication: This method supports secure, browser-based access from various platforms, including desktop applications, web applications, and headless machines.
Note: Choose the method that fits your needs based on the environment and level of security required.

Basic Authentication

Before you configure WordPress to use Basic Authentication, follow these guidelines:

  • Ensure that your WordPress login has administrative privileges.
  • Be aware of the version of WordPress running on the local host. Note: Versions 4.7 and later support the WordPress REST API natively, while earlier versions require a Basic Authentication plug-in to secure REST API access.

To configure Basic Authentication:

  1. Log into your WordPress host.
  2. If you are running an earlier WordPress version than 4.7, install the REST API plugin.
  3. Install the Basic Authentication plugin.
  4. To create custom taxonomies, install the Simple Taxonomy Refreshed plugin.
    If you prefer installing the plugins manually, extract the compressed folders to the wp-content\plugins folder and then enable the plugins via the WordPress admin interface.
  5. Next, set the following connection properties:

You are now ready to connect.

OAuth 2.0 Authentication

For all non-testing environments, WordPress supports OAuth authentication only. To enable this authentication from all OAuth flows, you must set AuthScheme to OAuth, and you must create a custom OAuth application.

The following subsections describe how to authenticate to WordPress from three common authentication flows. For information about how to create a custom OAuth application, see Creating a Custom OAuth Application. For a complete list of connection string properties available in WordPress, see Connection.

Desktop Applications
To authenticate with the credentials for a custom OAuth application, you must get and refresh the OAuth access token. After you do that, you are ready to connect.

Get and refresh the OAuth access token:

  • InitiateOAuth: Set this to GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
  • OAuthClientId: The client Id assigned when you registered your application.
  • OAuthClientSecret: The client secret that was assigned when you registered your application.
  • CallbackURL: The redirect URI that was defined when you registered your application.

When you connect, the driver opens WordPress's OAuth endpoint in your default browser. Log in and grant permissions to the application.

When the access token expires, the driver refreshes it automatically.

Automatic refresh of the OAuth access token:

To have the driver automatically refresh the OAuth access token, do the following:

  1. Before connecting to data for the first time, set the following connection parameters:
  2. On subsequent data connections, set the following:

OAuthClient Authentication
The client credentials grant type allows authentication from desktop applications or the web. To enable this authscheme, set AuthScheme to OAuthClient. This method requires a custom OAuth application, as described in Creating a Custom OAuth Application.

To connect, set these properties:

  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the access token in the connection string.
  • AuthScheme: Set the AuthScheme to OAuthClient to perform authentication with the client credentials grant type.
  • OAuthClientId: The client Id specified in your custom OAuth application.
  • OAuthClientSecret: The client secret specified in your custom OAuth application.
Headless Machines

If you need to log in to a resource that resides on a headless machine, you must authenticate on another device that has an internet browser. You can do this in either of the following ways:

  • Option 1: Obtain the OAuthVerifier value.
  • Option 2: Install the driver on a machine with an internet browser and transfer the OAuth authentication values after you authenticate through the usual browser-based flow.

After you execute either Option 1 or Option 2, configure the driver to automatically refresh the access token on the headless machine.

Option 1: Obtaining and Exchanging a Verifier Code

To obtain a verifier code, you must authenticate at the OAuth authorization URL. Do the following:

  1. Authenticate from the machine with an internet browser, and obtain the OAuthVerifier connection property.

    Set the following properties:

  2. Call the GetOAuthAuthorizationURL stored procedure. The stored procedure returns the CallbackURL established when the custom OAuth application was registered. (See Creating a Custom OAuth Application.)

    Copy this URL and paste it into a new browser tab.

  3. Log in and grant permissions to the driver. The OAuth application redirects you the redirect URI, with a parameter called code appended. Note the value of this parameter; you will need it later to configure the OAuthVerifier connection property.

  4. Exchange the OAuth verifier code for OAuth refresh and access tokens. On the headless machine, set the following connection properties to obtain the OAuth authentication values:

  5. Test the connection to generate the OAuth settings file.

  6. After you re-set the following properties, you are ready to connect:

    • InitiateOAuth: Set this to REFRESH.
    • OAuthSettingsLocation: The file containing the encrypted OAuth authentication values. To enable the automatic refreshing of the access token, be sure that this file gives read and write permissions to the driver.
    • OAuthClientId: The client Id assigned when you registered your application.
    • OAuthClientSecret: The client secret assigned when you registered your application.

Option 2: Transferring OAuth Settings

Prior to connecting on a headless machine, you must install and create a connection with the driver on a device that supports an internet browser. Set the connection properties as described above in "Desktop Applications".

After completing the instructions in "Desktop Applications", the resulting authentication values are encrypted and written to the path specified by OAuthSettingsLocation. The default filename is OAuthSettings.txt.

Test the connection to generate the OAuth settings file, then copy the OAuth settings file to your headless machine.

To connect to data via the headless machine, set the following connection properties:

  • InitiateOAuth: Set this to REFRESH.
  • OAuthSettingsLocation: The path to the OAuth settings file you copied from the machine with the browser. To enable automatic refreshing of the access token, ensure that this file gives read and write permissions to the driver.
  • OAuthClientId: The client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.

Okta

To connect to Okta, set these properties:

  • AuthScheme: Okta.
  • User: The authentiating Okta user.
  • Password: The password of the authenticating Okta user.
  • SSOLoginURL: The SSO provider's login URL.
  • SSOExchangeURL: The url used for the exchange of the SAML token for WordPress credentials. This is optional and if it is NULL WordPress will construct it.

If you are either using a trusted application or proxy that overrides the Okta client request OR configuring MFA, you must use combinations of SSOProperties to authenticate using Okta. Set any of the following, as applicable:

  • APIToken: When authenticating a user via a trusted application or proxy that overrides the Okta client request context, set this to the API Token the customer created from the Okta organization.
  • MFAType: If you have configured the MFA flow, set this to one of the following supported types: OktaVerify, Email, or SMS.
  • MFAPassCode: If you have configured the MFA flow, set this to a valid passcode.
    If you set this to empty or an invalid value, the driver issues a one-time password challenge to your device or email. After the passcode is received, reopen the connection where the retrieved one-time password value is set to the MFAPassCode connection property.
  • MFARememberDevice: True by default. Okta supports remembering devices when MFA is required. If remembering devices is allowed according to the configured authentication policies, the driver sends a device token to extend MFA authentication lifetime. If you do not want MFA to be remembered, set this variable to False.

Example connection string:

AuthScheme=Okta;SSOLoginURL='https://example.okta.com/home/appType/0bg4ivz6cJRZgCz5d6/46';User=oktaUserName;Password=oktaPassword;URL=YourWordpressSiteURL;

Azure AD

This configuration requires two separate Azure AD applications:

  • The "WordPress" application used for single sign-on, and
  • A custom OAuth application with user_impersonation permission on the Azure Active Directory.

To connect to Azure AD, set the AuthScheme to AzureAD, and set these properties:

  • SSOExchangeURL: The url used for the exchange of the SAML token for WordPress credentials. This is optional and if it is NULL WordPress will construct it.
  • OAuthClientId: The application Id of the connector application, listed in the Overview section of the app registration.
  • OAuthClientSecret: The client secret value of the connector application. Azure AD displays this when you create a new client secret.
  • CallbackURL: The redirect URI of the connector application. For example: https://localhost:33333.

To authenticate to Azure AD, set these required properties in SSOProperties:

  • Resource: The application Id URI of the WordPress application, listed in the app registration's Overview section. In most cases this is the URL of your custom WordPress domain.
  • AzureTenant: The Id of the Azure AD tenant where the applications are registered.

Example connection string:

AuthScheme=AzureAD;URL=YourWordpressSiteURL;OAuthClientId=3ea1c786-d527-4399-8c3b-2e3696ae4b48;OauthClientSecret=xxx;CallbackUrl=https://localhost:33333;SSOProperties='Resource=https://YourWordpressSite/wp-content/plugins/miniorange-saml-20-single-sign-on;AzureTenant=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
You are now ready to connect.

PingFederate

To connect to PingFederate, set the AuthScheme to PingFederate.

Before connecting, ensure that your WordPress site is configured with a PingFederate SSO plugin and that the authenticating user is provisioned in the PingFederate Data Store.

Set the following connection properties:

  • User: The PingFederate user. You must also add this user to PingFederate Data Stores. When connecting with a browser, you are redirected to the PingFederate login page to complete authentication.
  • Password: The PingFederate user's password.
  • SSOLoginURL: The PingFederate SSO login URL.
  • SSOExchangeURL (optional): The URL used for exchanging the SAML token for WordPress credentials. If not provided, the driver attempts to construct it automatically.

Example connection string:

AuthScheme=PingFederate;URL=https://yourwordpresssite.com;User=myuser@mydomain;Password=mypassword;SSOLoginURL=https://idp.example.com/idp/startSSO.ping;

Connecting to WordPress Online

WordPress Online supports two types of authentication methods:

  1. OAuth 2.0 authentication
  2. OAuth Password authentication

OAuth 2.0 Authentication

OAuth 2.0 is a protocol that allows applications to interact with blogs on WordPress, Your Way, and self-hosted WordPress sites running Jetpack.

The two authentication endpoints are the authorization endpoint and the token request endpoint.

  • https://public-api.wordpress.com/oauth2/authorize
  • https://public-api.wordpress.com/oauth2/token

Before you begin, you must create and register a custom OAuth application with WordPress.com, as described in Creating a Custom OAuth Application. This application provides the client Id, client secret, and redirect URI required to authenticate your application and verify API calls. You can create or manage your applications in the WordPress Applications Manager.

Use these values with the authorization endpoints, which require the following parameters:

When you are ready to connect, set the following connection properties:

There is an optional parameter available that can be used:

  • Scope: Defines the level of access that the authentication token grants to your application. Depending on the value set (or omitted), different access is allowed. Supported values include:
    • Auth: Grants access to /me endpoints for WordPress.com Connect.
    • Global: Grants full access to all the blogs associated with the user's account, including any Jetpack-connected sites. If omitted, access is limited to a single blog.

OAuth Password Authentication

Set the following connection properties:

  • Schema: WordPressOnline.
  • AuthScheme: OAuthPassword.
  • URL: Your WordPress Online URL.
  • OAuthClientId: The client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.
  • User: Your username.
  • Password: Your password.

Example connection strings:

AuthScheme=OAuthPassword;Schema=WordPressOnline;URL=https://example.wordpress.com;OAuthClientId=yourClientId;OAuthClientSecret=yourClientSecret;User=yourUser;Password=yourPassword;

AuthScheme=OAuth;Schema=WordPressOnline;URL=https://example.wordpress.com;InitiateOAuth=GETANDREFRESH;OAuthClientId=yourClientId;OAuthClientSecret=yourClientSecret;

Refreshing OAuth Values

The driver can refresh the temporary OAuth access tokens obtained during the browser-based OAuth authentication exchange. By default, the driver saves the encrypted tokens in the odbc.ini file corresponding to the DSN. Access to this odbc.ini file can be restricted in the case of System DSNs.

To enable the automatic token exchange, you can give the driver write access to the system odbc.ini. Or, you can set the OAuthSettingsLocation connection property to an alternate file path, to which the driver would have read and write access.

    OAuthSettingsLocation=/tmp/oauthsettings.txt
    

Installing Dependencies for OAuth Authentication

The OAuth authentication standard requires the authenticating user to interact with WordPress, using a web-browser. If the first OAuth interaction is to be done on the same machine the driver is installed on, for example, a desktop application, the driver needs access to the xdg-open program, which opens the default browser.

To satisfy this dependency, install the corresponding package with your package manager:

Debian/Ubuntu PackageRHEL/Fedora PackageFile
xdg-utilsxdg-utilsxdg-open

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-wordpress/lib/cdata.odbc.wordpress.ini':

[Driver]
AnsiCodePage = 932

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434