Skip to content

Commit 616c471

Browse files
vdk-plugin: json loads correction (#3416)
1 parent 9e449e9 commit 616c471

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

projects/vdk-plugins/vdk-oauth-auth/src/vdk/plugin/oauth/oauth_plugin.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ def vdk_initialize(self, context: CoreContext) -> None:
8080
# Scenario: data job running in local does not have oauth creds
8181
credentials_cache = LocalFolderCredentialsCache()
8282
credentials = credentials_cache.read_credentials()
83-
credentials = json.loads(credentials.replace("'", '"'))
84-
self.access_token = credentials.get("access_token")
83+
try:
84+
creds_json = json.loads(credentials)
85+
except json.JSONDecodeError as e:
86+
log.error(f"Try VDK login command and then try executing data job.")
87+
raise e
88+
self.access_token = creds_json.get("access_token")
8589
self.control_service_rest_api_url = (
8690
oauth_configuration.control_service_rest_api_url()
8791
)
@@ -114,10 +118,7 @@ def initialize_job(self, context: JobContext) -> None:
114118
# Retrieves details of an existing Data Job by specifying the name of the Data Job. | (Stable)
115119
oauth_creds = api_instance.oauth_credentials_get(self.team_name)
116120
except Exception as e:
117-
print(
118-
"Exception when calling DataJobsSecretsApi->oauth_credentials_get: %s\n"
119-
% e
120-
)
121+
log.error(f"Exception when fetching oauth credentials: {e}")
121122
raise e
122123
oauth_creds = oauth_creds.to_dict()
123124

0 commit comments

Comments
 (0)