Skip to content

Commit

Permalink
Merge pull request #28 from cloudsufi/cherrypick-oauth-3.14.4
Browse files Browse the repository at this point in the history
[Cherrypick][PLUGIN-1731][PLUGIN-1734] Fix Oauth issue and driver upgrade to 3.14.4
  • Loading branch information
vikasrathee-cs authored Jan 4, 2024
2 parents 553189b + 2dc31af commit 1b825cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<powermock.version>1.7.4</powermock.version>
<guice.version>4.0</guice.version>
<opencsv.version>2.4</opencsv.version>
<snowflake-jdbc.version>3.13.24</snowflake-jdbc.version>
<snowflake-jdbc.version>3.14.4</snowflake-jdbc.version>
</properties>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ private void initDataSource(SnowflakeBasicDataSource dataSource, BaseSnowflakeCo
if (config.getOauth2Enabled()) {
String accessToken = OAuthUtil.getAccessTokenByRefreshToken(HttpClients.createDefault(), config);
dataSource.setOauthToken(accessToken);
// The recommend way to pass token is in the password when you use the driver with connection pool.
// This is also a mandatory field, so adding the same.
// Refer https://github.com/snowflakedb/snowflake-jdbc/issues/1175
dataSource.setPassword(accessToken);
} else if (config.getKeyPairEnabled()) {
dataSource.setUser(config.getUsername());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public void validate(Schema inputSchema, FailureCollector failureCollector) {
* @param schema input schema to check
*/
private void validateInputSchema(Schema schema, FailureCollector failureCollector) {
// schema can be null in case it is a macro
if (schema == null) {
// return if schema is null or if any of the connection properties or table name is macro
if (schema == null || !canConnect() || containsMacro(PROPERTY_TABLE_NAME)) {
return;
}

Expand Down

0 comments on commit 1b825cb

Please sign in to comment.