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 Token URI (TokenURI) option.

Note: On Windows platforms, 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 "Obtaining access and refresh tokens using the Configuration Manager" for details.

To configure the driver to use the refresh token grant:

  • Set the Service URL (ServiceURL) options 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 Authentication Method (AuthenticationMethod) option to 24 (OAuth2). Since 24 (OAuth2) is the default, this value does not have to be specified in a connection URL used for OAuth 2.0 implementations.
  • Set the Client ID (ClientID) option to specify the client ID key for your application.
  • Set the Client Secret (ClientSecret) option 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 (TokenURI) option to specify the endpoint from which the driver fetches access tokens.
  • Set the RefreshToken (RefreshToken) option 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 string

DRIVER=DataDirect 8.0 Dynamics 365;ServiceURL=ServiceURL=https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/;
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;

odbc.ini file

[Microsoft Dynamics 365]
Driver=ODBCHOME/lib/ivdynamics36528.so
...
Description=DataDirect 8.0 MS Dynamics 365
...
ClientID=29453d6f-6789-25gh-gd8g-44tk3c527831
...
ClientSecret=12a3=bCD/EfGh4Ijk+Lm5P67qR8s=//TuV+WXy1Zabcd
...
TokenURI=POST https://login.microsoftonline.com/common/oauth2/v2.0/token
...
RefreshToken=12a3=bCD/EfGh4Ijk+Lgd8g-44tk3c527831
...
ServiceURL=ServiceURL=https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/
...