Sharashchandra commented on code in PR #47191:
URL: https://github.com/apache/airflow/pull/47191#discussion_r1975079154
##########
providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -185,6 +187,30 @@ def _get_field(self, extra_dict, field_name):
return extra_dict[field_name] or None
return extra_dict.get(backcompat_key) or None
+ def get_oauth_token(self, conn_config: dict) -> str:
+ """Generate temporary OAuth access token using refresh token in
connection details."""
+ url =
f"https://{conn_config['account']}.snowflakecomputing.com/oauth/token-request"
+ data = {
+ "grant_type": "refresh_token",
+ "refresh_token": conn_config["refresh_token"],
+ "redirect_uri": conn_config.get("redirect_uri",
"https://localhost.com"),
+ }
+ response = requests.post(
+ url,
+ data=data,
+ headers={
+ "Content-Type": "application/x-www-form-urlencoded",
+ },
+ auth=HTTPBasicAuth(conn_config["client_id"],
conn_config["client_secret"]), # type: ignore[arg-type]
Review Comment:
client_id is being picked up from the login field and client_secret is
picked up from the password field.
Login is a required field so that's always going to be there.
Missing password in already handled above so we'll always have either the
password or empty for the password key
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]