JDBC Driver for Salesforce Chatter

Build 21.0.7930

Connecting to SalesforceChatter

Salesforce Chatter uses OAuth 2.0 authentication. OAuth requires the authenticating user to interact with Salesforce Chatter using the browser. The driver facilitates this in various ways as described below.

Create a Connected App

You can follow the procedure below to register an app and obtain the OAuth client credentials, the OAuthClientId and OAuthClientSecret:

  1. Log into Salesforce.com.
  2. 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.
  3. Enter a name to be displayed to users when they log in to grant permissions to your app, along with a contact email address.
  4. 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 https://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. Note that you must redirect the user to an HTTPS URL.

  5. Select the scope of permissions that your app will request from the user, including Chatter.
  6. 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 Salesforce Chatter 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, https://localhost:portNumber.
  • 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:
  1. Extracts the access token from the callback URL and authenticates requests.
  2. Refreshes the access token when it expires.
  3. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.

Authenticate to Salesforce Chatter from a Web Application:

You can call stored procedures to authenticate from a Web application or if the driver is not authorized to open a browser window. To authenticate, set the following connection properties:

  • 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.

In this OAuth flow, you exchange a verifier code for the OAuthAccessToken:

  1. Call GetOAuthAuthorizationURL. The stored procedure returns the URL to the OAuth endpoint.
  2. Log in and authorize the application. You are redirected back to the callback URL. The callback URL contains the verifier code in the query string parameter named "code".
  3. Extract the verifier code and call GetOAuthAccessToken.
To connect to data, set OAuthAccessToken. Additionally, to automatically refresh the token, set OAuthRefreshToken and set InitiateOAuth to REFRESH.

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930