skip to main content
Using the driver : Authentication : OAuth 2.0 authentication : Access token flow
  

Try DataDirect Drivers Now
Access token flow
The access token authentication flow passes the access token directly from the client to the REST service for authentication. Unlike other grant types, authentication credentials, such as authorization codes, are not exchanged in return for the access code. Instead, the access token has been obtained from sources external to the flow and specified using the AccessToken property.
To use an access token flow:
*The application should be configured to set the AccessToken property to specify the access token required to authenticate to a REST service.
*Configure the minimum required properties required for a connection:
*If you are using a REST file, set the Config property to provide the name and location of the input REST file. For example, C:/path/to/yelp.rest.
*If you are using the Sample property, set the Sample property to specify the endpoint that the want to connect to and sample. For example, https://example.com/countries/.
*Set the AuthenticationMethod property to OAuth2.
The following examples demonstrate a basic Yelp session using an access token flow:
Using a connection URL:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:autorest:AccessToken='C3TQH9zjwek4CgJCU-4Mxb2DxLNfI2LB3a-dNfpWYx';
AuthenticationMethod=OAuth2;Config=C:/path/to/yelp.rest;");
Using a data source:
AutoRESTDataSource mds = new AutoRESTDataSource();
mds.setDescription("My Autonomous REST Data Source");
mds.setAccessToken("C3TQH9zjweek4CgJCU-4Mxb2DxPLNfI2LB3a-dNfpWnYx");
mds.setAuthenticationMethod("OAuth2");
mds.setConfig("C:/path/to/yelp.rest");