-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add response subtypes for different oauth2 grants (#1051)
* Add response subtypes for different oauth2 grants 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. * Update src/globus_sdk/authorizers/client_credentials.py Co-authored-by: Kurt McKee <contactme@kurtmckee.org> * Update src/globus_sdk/authorizers/client_credentials.py Co-authored-by: Kurt McKee <contactme@kurtmckee.org> * Minor docstring fixes * Update src/globus_sdk/authorizers/refresh_token.py Co-authored-by: Kurt McKee <contactme@kurtmckee.org> * Minor doc ordering fix * Rename the new OAuth token response classes Per discussion, this is a slight rename to restore the `OAuth` prefix and reduce the suffix to `Response`. --------- Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
- Loading branch information
Showing
16 changed files
with
170 additions
and
48 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
changelog.d/20240917_121333_sirosen_add_token_response_classes.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Changed | ||
~~~~~~~ | ||
|
||
- The response types for different OAuth2 token grants now vary by the grant | ||
type. For example, a ``refresh_token`` grant will now produce a | ||
``OAuthRefreshTokenResponse``. This allows code handling responses to identify | ||
which grant type was used to produce a response. (:pr:`NUMBER`) | ||
|
||
- The following new types have been introduced: | ||
``globus_sdk.OAuthRefreshTokenResponse``, | ||
``globus_sdk.OAuthAuthorizationCodeResponse``, | ||
``globus_sdk.OAuthClientCredentialsResponse``. | ||
|
||
- The ``RenewingAuthorizer`` class is now a generic over the response type | ||
which it handles, and the subtypes of authorizers are specialized for their | ||
types of responses. e.g., | ||
``class RefreshTokenAuthorizer(RenewingAuthorizer[OAuthRefreshTokenResponse])``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.