OAuth 2.0 authorization code grant
- Last Updated: May 16, 2025
- 2 minute read
- DataDirect Connectors
- JDBC
- Snowflake 6.0
- TeamCity 6.0
- Documentation
The authentication flow for the authorization code grant exchanges the authorization code and client credentials for the access token at the location specified by the RedirectURI. The following string includes the properties used to connect with the authorization code grant.
jdbc:datadirect:snowflake:AccountName=account_name;AuthenticationMethod=OAuth2;
AuthURI=auth_uri;DatabaseName=database_name;Schema=schema_name;
Warehouse=warehouse_name;ClientID=client_id;ClientSecret=client_secret;
RedirectURI=redirect_uri;[property=value[;...]];
where:
- account_name
- specifies the the full name of your account with region and cloud platform.
- database_name
-
specifies the name of the database to which you are connecting.
- schema_name
-
specifies the default schema to use for the specified database once connected. The specified schema should be an existing schema for which the specified default role has privileges.
- warehouse_name
-
specifies the virtual warehouse to use once connected. The specified warehouse should be an existing warehouse for which the specified default role has privileges.
- auth_uri
- specifies the endpoint for obtaining an authorization code from the authorization service.
- client_id
- specifies the client ID key for your application.
- client_secret
- specifies 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.
- redirect_uri
- specifies the endpoint that the client is returned to after authenticating with the service. This value must match the redirect URI specified in the Snowflake OAuth security integration.
- property=value
- specifies connection property settings. Multiple properties are separated by a semi-colon.
The following example connection string includes the properties required for connecting with the OAuth 2.0 authorization code grant.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:snowflake:AccountName=account_name.us-east-1;
AuthenticationMethod=OAuth2;DatabaseName=payroll;Schema=xyz;Warehouse=accounting;
AuthURI=https://account_name.us-east-1.snowflakecomputing.com/oauth/authorize;
ClientId=cd34efg5678h9ij87klm6543no32pqr10st987;
ClientSecret=098zyx765wvu432tsr123qpo456;
RedirectURI=http://localhost;");