Skip to content

Commit

Permalink
Incorporate PR feedback
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Rosen <1300022+sirosen@users.noreply.github.com>
  • Loading branch information
kurtmckee and sirosen committed Oct 18, 2024
1 parent b6eb71a commit a311113
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Changes
``InactiveTokenError`` is a subclass of ``ValueError``.

Existing code that calls ``AuthState.introspect_token()`` no longer returns ``None``, either,
but will instead raise ``ValueError``, a subclass of ``ValueError``,
or a ``globus_sdk.GlobusAPIError``:
but will instead raise ``ValueError`` (or a subclass) or a ``globus_sdk.GlobusAPIError``:

* ``AuthState.get_authorizer_for_scope``
* ``AuthState.effective_identity``
Expand Down
10 changes: 5 additions & 5 deletions src/globus_action_provider_tools/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _verify_introspect_result(self, introspect_result: GlobusHTTPResponse) -> No
"""

if not introspect_result["active"]:
raise InactiveTokenError("The token is invalid or has been revoked")
raise InactiveTokenError("The token is invalid.")

# validate scopes, ensuring that the token provided accords with the service's
# notion of what operations exist and are supported
Expand Down Expand Up @@ -239,7 +239,7 @@ def get_authorizer_for_scope(
``required_authorizer_expiration_time``, it is treated as a failure.
"""

had_cached_value, dependent_tokens = self._get_cached_dependent_tokens()
retrieved_from_cache, dependent_tokens = self._get_cached_dependent_tokens()

# if the dependent token data (which could have been cached) failed to meet
# the requirements...
Expand All @@ -251,8 +251,8 @@ def get_authorizer_for_scope(
# there's no reason to expect new tokens would do better
# fail, but do not clear the cache -- it could be satisfactory
# for some other scope request
if not had_cached_value:
raise ValueError("No matching cached dependent tokens found")
if not retrieved_from_cache:
raise ValueError("Dependent tokens do not match request.")

# otherwise, the cached value was bad -- fetch and check again,
# by clearing the cache and asking for the same data
Expand All @@ -264,7 +264,7 @@ def get_authorizer_for_scope(
if not self._dependent_token_response_satisfies_scope_request(
dependent_tokens, scope, required_authorizer_expiration_time
):
raise ValueError("Refreshed dependent tokens still don't match")
raise ValueError("Dependent tokens do not match request.")

token_data = dependent_tokens.by_scopes[scope]

Expand Down

0 comments on commit a311113

Please sign in to comment.