Connecting to Tableau CRM
OAuth requires the authenticating user to interact with Tableau CRM using the browser. The driver facilitates this in various ways as described in the following sections.
Create a Connected App
You can follow the procedure below to obtain the OAuth client credentials, the consumer key and consumer secret:
-
If your organization uses the Salesforce Lightning Experience UI, from Setup enter App in the Quick Find box, select App Manager (not Manage Connected Apps), and click New Connected App.
If your organization uses the Salesforce Classic UI, from Setup enter Apps in the Quick Find box and then select Apps, under Build or Create. Under Connected Apps, click New.
- Enter a name to be displayed to users when they log in to grant permissions to your app, along with a contact email address.
-
Click Enable OAuth Settings and enter a value in the Callback URL box.
If you are making a desktop application, set the Callback URL to http://localhost:33333 or a different port number of your choice.
If you are making a Web application, set the Callback URL to a page on your Web app you would like the user to be returned to after they have authorized your application.
-
Select the following OAuth scopes:
Access and manage your wave data (wave_api)
Access and manage your data (api)
Perform requests on your behalf at any time (refresh_token, offline_token)
- Once you have created the app, click your app name to open a page with information about your app. The OAuth client credentials, the consumer key and consumer secret, are displayed.
Authenticate to Tableau CRM from a Desktop Application
After setting the following connection properties, you are ready to connect:
- OAuthClientId: Set this to the consumer key in your app settings.
- OAuthClientSecret: Set this to the consumer secret in your app settings.
- CallbackURL: Set this to the callback URL in your app settings.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property.
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:
- Gets the callback URL and sets the access token to authenticate requests.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
- Exchanges the returned refresh token for a new, valid access token.
Authenticate to Tableau CRM from a Web Application
To obtain the access token, set the following connection properties and follow the steps below:
- OAuthClientId: Set this to the consumer key in your app settings.
- OAuthClientSecret: Set this to the consumer secret in your app settings.
- CallbackURL: Set this to the callback URL in your app settings.
- Call the GetOAuthAuthorizationURL stored procedure. The stored procedure returns the URL to the OAuth endpoint.
-
Log in and authorize the application. You are redirected back to the callback URL.
- If you set the Grant_Type parameter to "code", the callback URL contains the verifier code in the query string parameter named "code". Extract the verifier code and call the GetOAuthAccessToken stored procedure.
- OAuthAccessToken
- InstanceUrl
Refreshing Access Tokens
To automatically refresh the access token when it expires, set InitiateOAuth to "REFRESH" and set OAuthRefreshToken. Alternatively, call the RefreshOAuthAccessToken stored procedure when the access token expires. Given a refresh token as input, the procedure returns a valid OAuth access token.
Note: You can configure the session timeout in Salesforce by navigating to Setup -> Administration Setup -> Security Controls -> Session Settings.
Note: You can configure the session timeout in Salesforce by navigating to Setup > Administration Setup > Security Controls > Session Settings.
OAuthJWT Certificates
To obtain the OAuthJWT consumer key:
- Log in to Salesforce.com.
- From Setup, enter Apps in the Quick Find box and then click the link to create an app. In the Connected Apps section of the resulting page, click New.
- Enter a name to be displayed to users when they log in to grant permissions to your app, along with a contact Email address.
- Click Enable OAuth Settings and enter a value in the Callback URL box. Set this value only to create the Connected App as it is required. It will
not actually be needed for this type of authentication. The Callback URL is in the format:
http://localhost:8019/src/oauthCallback.rst
- Enable Use digital signatures.
- Upload your certificate.
- Select the scope of permissions that your app should request from the user.
- Click your app name to open a page with information about your app. The OAuth consumer key is displayed.
Note: This flow never issues a refresh token.