Configuring the driver to use OAuth 2.0
- Last Updated: November 18, 2022
- 2 minute read
- DataDirect Connectors
- JDBC
- Salesforce 6.0
- Documentation
Prerequisites:
- Client application registered as a Salesforce Connected App
- An access token or refresh token
After you have registered your client application as a Salesforce Connected App and obtained the required OAuth information, you may configure the driver to access Salesforce resources using OAuth 2.0.
To configure the driver, set the following connection properties:
- Set the AuthenticationMethod property to
oauth2.0. - Set the SchemaMap property to specify either the name or the absolute path and name of the configuration file where the map of the Salesforce data model is written. Note that a value for the SchemaMap property must be specified every time you authenticate to a Salesforce instance using OAuth 2.0.
- Set either of the following properties:
- Set the AccessToken property to specify the access token you have obtained from Salesforce. Generally, an access token is available for a short period of time and may only be used for a single session.
- Set the RefreshToken property to specify the refresh token you have obtained from Salesforce. With a valid refresh token, the driver can obtain a new access token. In this way, a refresh token enables application access to Salesforce for multiple sessions over an extended period of time, as dictated by your organization's policies.
If a value for the AccessToken property is not specified, the driver uses the value of the RefreshToken property to make a connection. If both values are not specified, the driver cannot make a successful connection. If both are specified, the driver ignores the AccessToken value and uses the RefreshToken value to generate a new AccessToken value.
See Obtaining access and refresh tokens with Postman for details on how to obtain access or refresh tokens using Postman.
Access token example URL
Connection conn = DriverManager.getConnection
("jdbc:datadirect:sforce://login.salesforce.com;AuthenticationMethod=oauth2.0;SchemaMap=schema-map-name;AccessToken=access-token;");
Refresh token example URL
Connection conn = DriverManager.getConnection
("jdbc:datadirect:sforce://login.salesforce.com;AuthenticationMethod=oauth2.0;SchemaMap=schema-map-name;RefreshToken=refresh-token;");