From 4a1c359a2f5969d60b8563fd87d610a5a080e692 Mon Sep 17 00:00:00 2001 From: Nathan Freeman Date: Fri, 13 Sep 2024 11:26:59 -0500 Subject: [PATCH] Add try/except to get auth url --- service/controllers/auth.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/service/controllers/auth.py b/service/controllers/auth.py index 697c4af..de60963 100644 --- a/service/controllers/auth.py +++ b/service/controllers/auth.py @@ -37,16 +37,19 @@ def get(self, client_id, endpoint_id): SCOPE = f"urn:globus:auth:scope:transfer.api.globus.org:all[*{DEPENDENT_SCOPE}]" else: logger.debug(f'endpoint is a gcp') - - session_client = client.oauth2_start_flow(refresh_tokens=True, requested_scopes=SCOPE) - authorize_url = client.oauth2_get_authorize_url() - # authorize_url = start_auth_flow(client) - logger.debug(f"successfully got auth url for client {client_id}") - return utils.ok( - result = {"url": authorize_url, "session_id": session_client.verifier}, - msg = f'Please go to the URL and login.' - ) + try: + session_client = client.oauth2_start_flow(refresh_tokens=True, requested_scopes=SCOPE) + + authorize_url = client.oauth2_get_authorize_url() + # authorize_url = start_auth_flow(client) + logger.debug(f"successfully got auth url for client {client_id}") + return utils.ok( + result = {"url": authorize_url, "session_id": session_client.verifier}, + msg = f'Please go to the URL and login.' + ) + except Exception as e: + logger.exception(e.__cause__) class TokensResource(Resource): """