Hossein Amini
05/03/2023, 10:41 AMloadTokens
again after the user logs in successfully in Bearer Authentication?
Normally when the user opens the app the loadTokens will be triggered and because there is no saved access token it returns BearerTokens(null, null)
. After the user logs in I save the access and refresh token in the database but loadTokens won’t be triggered again to set new access and refresh token. How can I force the Ktor to trigger loadTokens
again after the user logs in?
install(Auth) {
bearer {
loadTokens {
// Some code to retrieve access and refresh token from the database
BearerTokens(accessToken, refreshToken)
}
}
}
Rustam Siniukov
05/03/2023, 10:44 AMloadTokens
block should return null
where there is no valid tokenHossein Amini
05/03/2023, 10:56 AMRustam Siniukov
05/03/2023, 11:04 AMclient.plugin(Auth).providers.filterIsInstance<BearerAuthProvider>().first().clearToken()
it’s ugly, but should workHossein Amini
05/03/2023, 11:11 AMRustam Siniukov
05/03/2023, 11:19 AM