From d074635a6b8d5b9cf9d919c4c327e7a8b4f92ab6 Mon Sep 17 00:00:00 2001 From: Jacky Hu Date: Mon, 12 Dec 2022 22:12:27 -0800 Subject: [PATCH] Add none check on _oauth_persistence in DatabricksOAuthProvider Add none check on _oauth_persistence in DatabricksOAuthProvider to avoid app crash when _oauth_persistence is None. Signed-off-by: Jacky Hu --- src/databricks/sql/auth/authenticators.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/databricks/sql/auth/authenticators.py b/src/databricks/sql/auth/authenticators.py index 8209931da..b5b1dfcb3 100644 --- a/src/databricks/sql/auth/authenticators.py +++ b/src/databricks/sql/auth/authenticators.py @@ -88,9 +88,11 @@ def _initial_get_token(self): ) self._access_token = access_token self._refresh_token = refresh_token - self._oauth_persistence.persist( - self._hostname, OAuthToken(access_token, refresh_token) - ) + + if self._oauth_persistence: + self._oauth_persistence.persist( + self._hostname, OAuthToken(access_token, refresh_token) + ) except Exception as e: logging.error(f"unexpected error in oauth initialization", e, exc_info=True) raise e