Skip to content

Commit

Permalink
Automatically update bdbag keychain with bearer-token in get_credenti…
Browse files Browse the repository at this point in the history
…al since it might have been refreshed.

Don't build universal wheels anymore since Python 2 is no longer supported.
  • Loading branch information
mikedarcy committed Mar 15, 2024
1 parent 0bab22e commit fb70dc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions deriva/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def get_credential(host,
config_file=DEFAULT_CONFIG_FILE,
requested_scope=None,
force_scope_lookup=False,
match_scope_tag="deriva-all"):
match_scope_tag="deriva-all",
update_bdbag_keychain=True):
"""
This function is used to get authorization credentials (in dict form) for use with various deriva-py API calls
which take it as a parameter. A user must have already authenticated to the target host using either `deriva-auth`
Expand All @@ -36,7 +37,9 @@ def get_credential(host,
:param match_scope_tag: In the case that a host-to-scope mapping request returns multiple scopes, this is the key
value ("tag") to match against in the result dict. By convention, the default is set to "deriva-all", which is
the expected response from webauthn.
:param update_bdbag_keychain: Updates the bdbag keychain file with the bearer token mapped to `host`. This is
done to ensure that the bdbag keychain is updated when a refreshable bearer-token gets refreshed during the
login check. Defaults to True.
:return: A dict containing credential authorization values mapped by authorization type
"""
# load deriva credential set first
Expand Down Expand Up @@ -64,6 +67,8 @@ def get_credential(host,
match_scope_tag=match_scope_tag)
if token:
creds["bearer-token"] = token
if update_bdbag_keychain:
globus_client.update_bdbag_keychain(token=token, host=host)
except Exception as e:
logging.warning("Exception while getting Globus credentials: %s" % format_exception(e))

Expand Down
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[metadata]
description-file = README.md
description_file = README.md
license_file = LICENSE
[bdist_wheel]
universal = 1

0 comments on commit fb70dc7

Please sign in to comment.