OAuth 2.0 access token flow
- Last Updated: July 31, 2023
- 2 minute read
- DataDirect Connectors
- JDBC
- Snowflake 6.0
- TeamCity 6.0
- Documentation
The access token authentication flow passes the token directly from the client to the Snowflake instance for authentication. The token is obtained from sources external to the flow and specified using the AccessToken property. The following string includes the properties used to connect with the access token flow.
jdbc:datadirect:snowflake:AccountName=account_name;AuthenticationMethod=OAuth2;
AccessToken=access_token;DatabaseName=database_name;Schema=schema_name;
Warehouse=warehouse_name;[property=value[;...]];
where:
- account_name
-
specifies the full name of your account with region and cloud platform.
- access_token
-
specifies the access token required to authenticate to Snowflake. This property allows you to set the token manually.
Important:
- The access token is a confidential value used to authenticate to the server. To prevent unauthorized access, this value must be securely maintained.
- Access tokens expire ten minutes after generation. Once connected, the access token remains valid till the session is disconnected.
- 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.
- 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 access token flow.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:snowflake:AccountName=account_name.us-east-1;
AuthenticationMethod=OAuth2;AccessToken=abc12cd34efg5678h9ij87klm6543no32pqr10;
DatabaseName=payroll;Schema=xyz;Warehouse=accounting;");