-
Notifications
You must be signed in to change notification settings - Fork 184
Add support for federated connection token exchange #670
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,7 +195,6 @@ def refresh_token( | |
|
|
||
| Args: | ||
| refresh_token (str): The refresh token returned from the initial token request. | ||
|
|
||
| scope (str): Use this to limit the scopes of the new access token. | ||
| Multiple scopes are separated with whitespace. | ||
|
|
||
|
|
@@ -236,7 +235,6 @@ def passwordless_login( | |
| Multiple scopes are separated with whitespace. | ||
|
|
||
| audience (str): The unique identifier of the target API you want to access. | ||
|
|
||
| Returns: | ||
| access_token, id_token | ||
| """ | ||
|
|
@@ -277,3 +275,39 @@ def backchannel_login( | |
| "grant_type": grant_type, | ||
| }, | ||
| ) | ||
|
|
||
| def federated_connection_token( | ||
| self, | ||
| refresh_token: str, | ||
| connection: str, | ||
| login_hint: str | None = None, | ||
| ) -> Any: | ||
| """Calls oauth/token endpoint with token-exchange:federated-connection-access-token grant type | ||
|
|
||
| Args: | ||
| refresh_token (str): The refresh token returned from the initial token request. | ||
|
|
||
| connection (str): The name of the connection to use. | ||
|
|
||
| login_hint (str, optional): The login hint to use. | ||
|
|
||
| Returns: | ||
| access_token, expires_in, scope, issued_token_type, token_type | ||
| """ | ||
|
|
||
| data = { | ||
| "client_id": self.client_id, | ||
| "grant_type": "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token", | ||
| "connection": connection, | ||
| "subject_token": refresh_token, | ||
| "subject_token_type": "urn:ietf:params:oauth:token-type:refresh_token", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it work with all token types i.e. id_token, m2m_refresh_token?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean, there is nothing to support additional token_types here, this only works with refresh tokens. |
||
| "requested_token_type": "http://auth0.com/oauth/token-type/federated-connection-access-token", | ||
| } | ||
|
|
||
| if login_hint: | ||
| data["login_hint"] = login_hint | ||
|
|
||
| return self.authenticated_post( | ||
| f"{self.protocol}://{self.domain}/oauth/token", | ||
| data=data, | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure on the required fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, connection and refresh_token are required. login_hint is optional.