Configuring a Connection
After Installing the Connector you can connect and create a Data Source for data in WordPress.
Setting Up a Data Source
Complete the following steps to connect to the data:
- Under Connect | To a Server, click More....
- Select the data source called WordPress by CData.
- Enter the information required for the connection.
- Click Sign In.
- If necessary, select a Database and Schema to discover what tables and views are available.
Using the Connection Builder
The connector makes the most common connection properties available directly in Tableau. However, it can be difficult to use if you need to use more advanced settings or need to troubleshoot connection issues. The connector includes a separate connection builder that allows you to create and test connections outside of Tableau.
There are two ways to access the connection builder:
- On Windows, use a shortcut called Connection Builder in the Start menu, under the CData Tableau Connector for WordPress folder.
- You can also start the connection builder by going to the driver install directory and running the .jar file in the lib directory.
In the connection builder, you can set values for connection properties and click Test Connection to validate that they work. You can also use the Copy to Clipboard button to save the connection string. This connection string can be given to the Connection String option included in the connector connection window in Tableau.
Connecting to WordPress
CData Tableau Connector 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.
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:
- Log into your WordPress host.
- If you are running an earlier WordPress version than 4.7, install the REST API plugin.
- Install the Basic Authentication plugin.
- 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. - Next, set the following connection properties:
- AuthScheme: Set this to Basic.
- URL: Your WordPress URL.
- User: Your username.
- Password: Your password.
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 connector opens WordPress's OAuth endpoint in your default browser. Log in and grant permissions to the application.
After you grant permissions to the application, the connector then completes the OAuth process:
- The connector obtains an access token from WordPress and uses it to request data.
- The OAuth values are saved in the path specified in OAuthSettingsLocation. These values persist across connections.
When the access token expires, the connector refreshes it automatically.
Automatic refresh of the OAuth access token:
To have the connector automatically refresh the OAuth access token, do the following:
- Before connecting to data for the first time, set the following connection parameters:
- InitiateOAuth: Set this to REFRESH.
- OAuthClientId: The client Id in your application settings.
- OAuthClientSecret: The client secret in your application settings.
- OAuthAccessToken: The access token returned by GetOAuthAccessToken.
- OAuthSettingsLocation: The path where you want the connector to save the OAuth values, which persist across connections.
- 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 connector 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:
-
Authenticate from the machine with an internet browser, and obtain the OAuthVerifier connection property.
Set the following properties:
- InitiateOAuth: Set this to OFF.
- OAuthClientId: The client Id assigned when you registered your application.
- OAuthClientSecret: The client secret assigned when you registered your application.
-
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.
-
Log in and grant permissions to the connector. 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.
-
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:
- InitiateOAuth: Set this to REFRESH.
- OAuthVerifier: The noted verifier code (the value of the Code parameter in the redirect URI).
- OAuthSettingsLocation: Persist the encrypted OAuth authentication values to the specified file.
- OAuthClientId: The client Id in your custom OAuth application settings.
- OAuthClientSecret: The client secret in the custom OAuth application settings.
-
Test the connection to generate the OAuth settings file.
-
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 connector.
- 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 connector.
- 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 connector 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 connector 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.
- InitiateOAuth: Set this to GETANDREFRESH.
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;InitiateOAuth=GETANDREFRESH;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 connector 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:- OAuth 2.0 authentication
- 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:
- Schema: WordPressOnline.
- AuthScheme: OAuth.
- URL: Your WordPress.com site URL.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: The client Id from your WordPress.com application.
- OAuthClientSecret: The client secret from your WordPress.com application.
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;
Next Step
See Using the Connector to create data visualizations.