Authorization code grant
- Last Updated: July 2, 2025
- 1 minute read
- DataDirect Connectors
- JDBC
- Aha! 6.0
- Documentation
Note: To use OAuth2 authentication, you must first register your application with Aha!.
Refer to the Aha! documentation for more information.
The authorization code grant is a commonly used authentication flow for web and native applications. It provides secure connections by requiring multiple points of authentication before permitting access to data. When using the authorization code flow, the application is first redirected to the location hosting the temporary authorization code and retrieves it. Next, after being redirected to the location specified by the RedirectURI property, the application exchanges the authorization code, client ID, and client secret for the access token.
To use an authorization code grant:
- The application should be configured to set the OAuthCode property to specify the authorization code that is exchanged for the access token.
- Set the ServerName property to specify the base URL of the Aha! service to which you want to issue requests. For example, company.aha.io.
- Set the AuthenticationMethod property to
OAuth2. - Set the ClientID property to specify the client ID key for your application.
- Set the ClientSecret property to specify the client ID key for your application.
- Set the RedirectURI to specify the endpoint to which the client is returned after third-party authorization. This value is the same as the one specified in the OAuth application.
The following example demonstrates using an authorization code grant:
Using a connection URL:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:aha://company.aha.io;authenticationMethod=OAuth2;
oauthCode=abc12cd34efg5678h9ij87klm6543no32pqr10;
clientId=cd34efg5678h9ij87klm6543no32pqr10st987;
clientSecret=098zyx765wvu432tsr123qpo456;
redirectUri=https://lvh.me/app_callback.html;");
Using a data source:
AutoRESTDataSource mds = new AhaDataSource();
mds.setDescription("My Aha Data Source");
mds.setServerName("company.aha.io");
mds.setAuthenticationMethod("OAuth2");
mds.setOAuthCode("abc12cd34efg5678h9ij87klm6543no32pqr10");
mds.setClientID("cd34efg5678h9ij87klm6543no32pqr10st987");
mds.setClientSecret("098zyx765wvu432tsr123qpo456");
mds.setredirectURI("https://lvh.me/app_callback.html");