purbanow commented on a change in pull request #12618:
URL: https://github.com/apache/beam/pull/12618#discussion_r481963151



##########
File path: 
sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
##########
@@ -1532,26 +1767,47 @@ public DataSource buildDatasource() {
         SnowflakeBasicDataSource basicDataSource = new 
SnowflakeBasicDataSource();
         basicDataSource.setUrl(buildUrl());
 
-        if (getUsername() != null) {
-          basicDataSource.setUser(getUsername());
+        if (isNotEmpty(getOauthToken())) {
+          basicDataSource.setOauthToken(getOauthToken().get());
+        } else if (isNotEmpty(getUsername()) && getPrivateKey() != null) {
+          basicDataSource.setUser(getUsername().get());
+          basicDataSource.setPrivateKey(getPrivateKey());
+        } else if (isNotEmpty(getUsername())
+            && isNotEmpty(getPrivateKeyPassphrase())
+            && isNotEmpty(getRawPrivateKey())) {
+          PrivateKey privateKey =
+              KeyPairUtils.preparePrivateKey(
+                  getRawPrivateKey().get(), getPrivateKeyPassphrase().get());
+          basicDataSource.setPrivateKey(privateKey);
+          basicDataSource.setUser(getUsername().get());
+
+        } else if (isNotEmpty(getUsername()) && isNotEmpty(getPassword())) {
+          basicDataSource.setUser(getUsername().get());
+          basicDataSource.setPassword(getPassword().get());
+        } else {
+          throw new RuntimeException("Missing credentials values. Please check 
your credentials");

Review comment:
       Before using provided credentials we're checking them using `isNotEmpty` 
method. 
   
   We tested it with dataflow templates by providing credentials from Dataflow 
UI. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to