skip to main content
Using the driver : Authentication : OAuth 2.0 authentication : Password grant
  

Try DataDirect Drivers Now
Password grant
The authentication flow for the password grant exchanges user credentials for the access token at the location specified by the TokenURI. For added security, client credentials, such as the client ID and client Secret, might also be authenticated for some flows.
To configure the driver to use an authentication flow for a password grant:
*Configure the minimum 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/zendesk.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.
*Set the User property to specify the user name that is used to fetch the access token from the Token endpoint.
*Set the Password property to specify the password used to fetch the access token.
*Set the TokenURI property to specify the endpoint used to exchange authentication credentials for access tokens. For example, https://example.com/oauth2/authorize/.
*If required by your REST service, set the ClientID property to specify the client ID key for your application.
*If required by your REST service, 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.
*Optionally, set the Scope property to specify a space-separated list of OAuth scopes to limit the permissions granted by the access token.
The following example demonstrates a basic Zendesk session using a password grant:
Using a connection string:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:autorest:AuthenticationMethod=OAuth2;
Config=C:/path/zendesk.rest;TokenURI=https://accounts.google.com/o/oauth2/token;
User='jjones@example.com';Password='secretstuff';");
Using a data source:
AutoRESTDataSource mds = new AutoRESTDataSource();
mds.setDescription("My Autonomous REST Data Source");
mds.setAuthenticationMethod("OAuth2");
mds.setConfig("C:/path/zendesk.rest");
mds.setTokenURI("https://accounts.google.com/o/oauth2/token");
mds.setUser("jjones@example.com");
mds.setPassword("secretstuff");