The refresh token grant is used to request a new access token or renew an expired one by exchanging the refresh token at the endpoint specified by the TokenURI property. The following string includes the properties used to connect with the refresh token grant.

jdbc:datadirect:snowflake:AccountName=account_name;AuthenticationMethod=OAuth2;
DatabaseName=database_name;Schema=schema_name;Warehouse=warehouse_name;
ClientID=client_id;ClientSecret=client_secret;TokenURI=token_uri;
RefreshToken=refresh_token;[property=value[;...]];

where:

account_name

specifies 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.

client_id

specifies the client ID 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.
token_uri

specifies the endpoint from which the driver fetches access tokens.

refresh_token
specifies the refresh token used to either request a new access token or renew an expired access token.
Important: The refresh token is a confidential value used to authenticate to the server. To prevent unauthorized access, this value must be securely maintained.
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;DatabaseName=payroll;Schema=xyz;
  Warehouse=accounting;ClientID=123456789;ClientSecret=FaZBFRsGXTaR;
  TokenURI=https://account_name.us-east-1.snowflakecomputing.com/oauth/token-request;
  RefreshToken=abc12cd34efg5678h9ij87klm6543no32pqr10;");