From 763d86e39fadf28bbf6d84db82062a91244cbe2e Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 15 Aug 2023 13:25:54 -0500 Subject: [PATCH] Fix an always-raising code example --- .../auth_manage_projects/manage_projects.py | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/docs/examples/auth_manage_projects/manage_projects.py b/docs/examples/auth_manage_projects/manage_projects.py index 8ba516dbf..77c6d8f0b 100644 --- a/docs/examples/auth_manage_projects/manage_projects.py +++ b/docs/examples/auth_manage_projects/manage_projects.py @@ -92,37 +92,38 @@ def main(): try: execute(parser, args) except globus_sdk.GlobusAPIError as err: - if err.info.authorization_parameters: - err_params = err.info.authorization_parameters - session_params = {} - if err_params.session_required_identities: - print("session required identities detected") - session_params[ - "session_required_identities" - ] = err_params.session_required_identities - if err_params.session_required_single_domain: - print("session required single domain detected") - session_params[ - "session_required_single_domain" - ] = err_params.session_required_single_domain - if err_params.session_required_policies: - print("session required policies detected") - session_params[ - "session_required_policies" - ] = err_params.session_required_policies - print(session_params) - print(err_params) - response = do_login_flow(session_params=session_params) - # now store the tokens - MY_FILE_ADAPTER.store(response) - print( - "Reauthenticated successfully to satisfy " - "session requirements. Will now try again.\n" - ) - - # try the action again - execute(parser, args) - raise + if not err.info.authorization_parameters: + raise + + err_params = err.info.authorization_parameters + session_params = {} + if err_params.session_required_identities: + print("session required identities detected") + session_params[ + "session_required_identities" + ] = err_params.session_required_identities + if err_params.session_required_single_domain: + print("session required single domain detected") + session_params[ + "session_required_single_domain" + ] = err_params.session_required_single_domain + if err_params.session_required_policies: + print("session required policies detected") + session_params[ + "session_required_policies" + ] = err_params.session_required_policies + print(session_params) + print(err_params) + response = do_login_flow(session_params=session_params) + # now store the tokens + MY_FILE_ADAPTER.store(response) + print( + "Reauthenticated successfully to satisfy " + "session requirements. Will now try again.\n" + ) + + # try the action again + execute(parser, args) def execute(parser, args):