Skip to content

Commit

Permalink
Merge pull request #807 from globus/fix-always-raise-example
Browse files Browse the repository at this point in the history
Fix an always-raising code example
  • Loading branch information
kurtmckee authored Aug 15, 2023
2 parents 4375e64 + 763d86e commit 073bf87
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions docs/examples/auth_manage_projects/manage_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 073bf87

Please sign in to comment.