Refresh token grant
- Last Updated: October 25, 2022
- 2 minute read
- DataDirect Connectors
- JDBC
- Microsoft Dynamics 365 6.0
- Documentation
The refresh token grant is used to replace expired access tokens with active ones by exchanging the refresh token at the endpoint specified by the TokenURI property.
Note: As opposed to using a
third-party application such as Postman, you can use the Progress DataDirect Dynamics 365
Configuration Manager to obtain a refresh token to support the refresh token grant. See
Obtain access and refresh tokens using
the Configuration Manager for details.
To configure the driver to use the refresh token grant:
- Set the ServiceURL property to the base URL of the Dynamics 365 instance to which you want to issue requests. For example, https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/.
- Set the AuthenticationMethod property to
OAuth2. SinceOAuth2is the default, this value does not have to be specified in a connection URL used for OAuth 2.0 implementations. - Set the ClientID property to specify the client ID key for your application.
- Set the ClientSecret property to specify the client secret for your
application.Important: The client secret is a confidential value used to authenticate the application to the server. To prevent unauthorized access, this value must be securely maintained.
- Set the TokenURI property to specify the endpoint from which the driver fetches access tokens.
- Set the RefreshToken property to specify the refresh token used to
request a new access token or renew an expired one. Important: The refresh token is a confidential value used to authenticate to the server. To prevent unauthorized access, this value must be securely maintained.
The following examples show the connection information required to establish a session using the refresh token grant.
Connection URL
Connection conn = DriverManager.getConnection
("jdbc:datadirect:dynamics365:
ServiceURL=https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/;
AuthenticationMethod=OAuth2;ClientID=29453d6f-6789-25gh-gd8g-44tk3c527831;
ClientSecret=12a3=bCD/EfGh4Ijk+Lm5P67qR8s=//TuV+WXy1Zabcd;
TokenURI=https://login.microsoftonline.com/common/oauth2/v2.0/token;
RefreshToken=12a3=bCD/EfGh4Ijk+Lgd8g-44tk3c527831;");
Data Source
Dynamics365DataSource mds = new Dynamics365DataSource();
mds.setDescription("My Dynamics 365 Data Source");
mds.setServiceURL("https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/");
mds.AuthenticationMethod("OAuth2");
mds.setClientID("29453d6f-6789-25gh-gd8g-44tk3c527831");
mds.setClientSecret("12a3=bCD/EfGh4Ijk+Lm5P67qR8s=//TuV+WXy1Zabcd");
mds.setTokenURI("https://login.microsoftonline.com/common/oauth2/v2.0/token");
mds.setRefreshToken("12a3=bCD/EfGh4Ijk+Lgd8g-44tk3c527831");