Conversation
EXAMPLES.md
Outdated
|
|
||
| This feature allows you to authenticate a user in a web session using the refresh token obtained from the native session without requiring the user to log in again. | ||
|
|
||
| Call the api to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` end point. |
There was a problem hiding this comment.
| Call the api to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` end point. | |
| Call the API to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` end point. |
auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.kt
Outdated
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.kt
Outdated
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt
Outdated
Show resolved
Hide resolved
|
|
||
| /** | ||
| * Fetches a new [SSOCredentials] . It will fail with [CredentialsManagerException] | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| } | ||
|
|
||
| /** | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| * Fetches a new [SSOCredentials] . It will fail with [CredentialsManagerException] | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
| * @param ssoCredentials the credentials to save in the storage. | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
|
|
||
| /** | ||
| * Helper method to store the given [SessionTransferCredentials] refresh token in the storage. | ||
| * Method will silently return ,if the passed credentials has no refresh token. |
There was a problem hiding this comment.
| * Method will silently return ,if the passed credentials has no refresh token. | |
| * Method will silently return if the passed credentials have no refresh token. |
| * the client. Method will silently return ,if the passed credentials has no refresh token. | ||
| * | ||
| * @param ssoCredentials the credentials to save in the storage. | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| * @param ssoCredentials the credentials to save in the storage. | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
|
|
||
| /** | ||
| * Fetches a new [SSOCredentials] . It will fail with [CredentialsManagerException] | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
| val exception = when { | ||
| error.isRefreshTokenDeleted || | ||
| error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED | ||
| error.isRefreshTokenDeleted || error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED |
There was a problem hiding this comment.
Should we throw a distinct error here?
|
|
||
| /** | ||
| * Fetches a new [SSOCredentials] . It will fail with [CredentialsManagerException] | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| * Fetches a new [SSOCredentials] . It will fail with [CredentialsManagerException] | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
| } | ||
|
|
||
| /** | ||
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] |
There was a problem hiding this comment.
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | |
| * Fetches a new [SessionTransferCredentials]. It will fail with [CredentialsManagerException] |
| * Fetches a new [SessionTransferCredentials] . It will fail with [CredentialsManagerException] | ||
| * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token, | ||
| * if a new one is issued | ||
| * if a new one is issued. |
There was a problem hiding this comment.
| * if a new one is issued. | |
| * if a new one is issued. |
auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt
Show resolved
Hide resolved
|
|
||
| /** | ||
| * Helper method to stores the given [SessionTransferCredentials] refresh token in the storage. | ||
| * Method will silently return ,if the passed credentials has no refresh token. |
There was a problem hiding this comment.
| * Method will silently return ,if the passed credentials has no refresh token. | |
| * Method will silently return if the passed credentials have no refresh token. |
| return | ||
| } | ||
| // Checking if the existing one needs to be replaced with the new one | ||
| if (existingCredentials.refreshToken == sessionTransferCredentials.refreshToken && existingCredentials.idToken == sessionTransferCredentials.idToken) return |
There was a problem hiding this comment.
There's no need to check the ID token for equality, as the newer one will have a different iat (issued at) claim value, so the token values will always be different.
There was a problem hiding this comment.
So we can always replace the old ID token with the new one.
auth0/src/main/java/com/auth0/android/result/SessionTransferCredentials.kt
Outdated
Show resolved
Hide resolved
|
|
||
| /** | ||
| * Holds the session token credentials required for web SSO . | ||
| * Holds the token credentials required for web SSO . |
There was a problem hiding this comment.
| * Holds the token credentials required for web SSO . | |
| * Holds the token credentials required for web SSO. |
| public data class SessionTransferCredentials( | ||
| /** | ||
| * The Session Token used for web SSO . | ||
| * The token used for web SSO . |
There was a problem hiding this comment.
| * The token used for web SSO . | |
| * The token used for web SSO. |
auth0/src/main/java/com/auth0/android/result/SessionTransferCredentials.kt
Outdated
Show resolved
Hide resolved
| @field:SerializedName("id_token") public val idToken: String, | ||
|
|
||
| /** | ||
| * Type of the token issued.In this case, an Auth0 web sso token |
There was a problem hiding this comment.
| * Type of the token issued.In this case, an Auth0 web sso token | |
| * Type of the token issued. In this case, an Auth0 web sso token. |
auth0/src/main/java/com/auth0/android/result/SessionTransferCredentials.kt
Outdated
Show resolved
Hide resolved
EXAMPLES.md
Outdated
|
|
||
| This feature allows you to authenticate a user in a web session using the refresh token obtained from the native session without requiring the user to log in again. | ||
|
|
||
| Call the API to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` end point by passing as a query parameter or a cookie value. |
There was a problem hiding this comment.
| Call the API to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` end point by passing as a query parameter or a cookie value. | |
| Call the API to fetch a webSessionTransferToken in exchange for a refresh token. Use the obtained token to authenticate the user by calling the `/authorize` endpoint, passing the token as a query parameter or a cookie value. |
| cookieManager.setAcceptCookie(true) | ||
| cookieManager.setCookie( | ||
| url, | ||
| "session_token=$sessionToken; path=/" |
There was a problem hiding this comment.
Should session_token=$sessionToken; path=/ be auth0_session_transfer_token=$sessionToken; path=/?
There was a problem hiding this comment.
This file is not required anymore. Missed deleting it. Thanks for bringing this to notice
| * * *expiresIn*: The token expiration duration. | ||
| * * *issuedTokenType*: Type of the token issued. | ||
| * | ||
| * Holds the token credentials required for web SSO . |
There was a problem hiding this comment.
| * Holds the token credentials required for web SSO . | |
| * Holds the token credentials required for web SSO. |
| public data class SSOCredentials( | ||
| /** | ||
| * The Session Token used for web SSO . | ||
| * The token used for web SSO . |
There was a problem hiding this comment.
| * The token used for web SSO . | |
| * The token used for web SSO. |
| * Expiration duration of the session token in seconds. Session tokens are short-lived and expire after a few minutes. | ||
| * Once expired, the Session Token can no longer be used for SSO. | ||
| * Expiration duration of the session transfer token in seconds. Session transfer tokens are short-lived and expire after a few minutes. | ||
| * Once expired, the session transfer tokens can no longer be used for web SSO. |
There was a problem hiding this comment.
| * Once expired, the session transfer tokens can no longer be used for web SSO. | |
| * Once expired, the session transfer tokens can no longer be used for web SSO. |
| import com.auth0.android.Auth0 | ||
|
|
||
| /** | ||
| * Provider class to handle native to web sso |
There was a problem hiding this comment.
| * Provider class to handle native to web sso | |
| * Provider class to handle native to web SSO. |
| @field:SerializedName("id_token") public val idToken: String, | ||
|
|
||
| /** | ||
| * Type of the token issued.In this case, an Auth0 session transfer token |
There was a problem hiding this comment.
| * Type of the token issued.In this case, an Auth0 session transfer token | |
| * Type of the token issued. In this case, an Auth0 session transfer token. |
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors