Skip to content

Get Token Information ​

To get information, you can use the TokenProvider. This will assist you in getting token-related information and performing actions on the tokens.

kotlin
val tokenProvider: TokenProvider = asgardeoAuth.getTokenProvider()

To get the token-related information, you can use the following functions:

kotlin
val accessToken: String? = tokenProvider.getAccessToken(context)
val idToken: String? = tokenProvider.getIDToken(context)
val refreshToken: String? = tokenProvider.getRefreshToken(context)
val accessTokenExpirationTime: Long? = tokenProvider.getAccessTokenExpirationTime(context)
val scope:String? = tokenProvider.getScope(context)

Perform action based on the tokens ​

If you want to perform any action based on the tokens that are returned, you can use the performAction function in the TokenProvider.

kotlin
tokenProvider.performAction(context) { accessToken, idToken, ->
    action(accessToken, idToken)
}

NOTE

All the functions mentioned above are suspend functions. Therefore, you need to call them inside a coroutine.