Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response subtypes for different oauth2 grants #1051

Merged
merged 7 commits into from
Sep 17, 2024

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Sep 17, 2024

The initial goal of this work is to allow a function handling a token
response, e.g., in a tokenstorage interface, to determine the context
in which the original call was made. It is now possible to check

if isinstance(response, OAuthRefreshTokenResponse): ...

in a generic token handler.

Additionally, this opens the way for distinct token response objects
to implement methods which vary based on the known properties of their
respective grant types. For example, OAuthRefreshTokenResponse could
raise a more informative error when decode_id_token is called and
no id_token is present.


📚 Documentation preview 📚: https://globus-sdk-python--1051.org.readthedocs.build/en/1051/

The initial goal of this work is to allow a function handling a token
response, e.g., in a tokenstorage interface, to determine the context
in which the original call was made. It is now possible to check

    if isinstance(response, RefreshTokenResponse): ...

in a generic token handler.

Additionally, this opens the way for distinct token response objects
to implement methods which vary based on the known properties of their
respective grant types. For example, RefreshTokenResponse could
raise a more informative error when `decode_id_token` is called and
no `id_token` is present.
docs/services/auth.rst Outdated Show resolved Hide resolved
src/globus_sdk/authorizers/client_credentials.py Outdated Show resolved Hide resolved
src/globus_sdk/authorizers/client_credentials.py Outdated Show resolved Hide resolved
src/globus_sdk/authorizers/client_credentials.py Outdated Show resolved Hide resolved
src/globus_sdk/authorizers/refresh_token.py Outdated Show resolved Hide resolved
src/globus_sdk/authorizers/refresh_token.py Outdated Show resolved Hide resolved
sirosen and others added 5 commits September 17, 2024 13:18
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
Per discussion, this is a slight rename to restore the `OAuth` prefix
and reduce the suffix to `Response`.
@sirosen sirosen merged commit a6cb13d into globus:main Sep 17, 2024
15 checks passed
@sirosen sirosen deleted the add-token-response-classes branch September 17, 2024 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants