The access token flow passes the access token directly from the client to the Dynamics 365 service for authentication.

Note: As opposed to using a third-party application such as Postman, you can use the Progress DataDirect Dynamics 365 Configuration Manager to obtain an access token to support the access token flow. See Obtain access and refresh tokens using the Configuration Manager for details.
Note: Access tokens are temporary and must be replaced to maintain the session without interruption. The life of an access token is typically one hour.

To configure the driver to use an access token flow:

  • 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. Since OAuth2 is the default, this value does not have to be specified in a connection URL used for OAuth 2.0 implementations.
  • Set the AccessToken property to the value of the access token obtained from external sources.

The following examples show the connection information required to establish a session using the access token flow.

Connection URL

Connection conn = DriverManager.getConnection
  ("jdbc:datadirect:dynamics365:
    ServiceURL=https://mywebinstance.api.crm.dynamics.com/api/data/v9.1/;
    AuthenticationMethod=OAuth2;
    AccessToken=C3TQH9zjwek4CgJCU-4Mxb2DxLNfI2LB3a-dNfpWYx;");

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.setAuthenticationMethod("OAuth2");
mds.setAccessToken("C3TQH9zjweek4CgJCU-4Mxb2DxPLNfI2LB3a-dNfpWnYx");