I cannot find the answer on how to refresh access tokens using Amplify on Android.
In the documentation and on some forums it was suggested that it all happens automatically but in my case, it does not.
In the app I use Amplify.Auth for user authentication, also Amplify.Storage and Amplify.Predictions. To query database I use DynamoDBMapper.
I tried:
auth.currentUserto force token refresh but it seems it doesn't workAWSMovileClient.getInstance().tokensuses cached tokens onlyAWSMobileClient.getInstance().currentUserState()to refresh it manuallyAmplify.Auth.fetchAuthSession()is the technique I use now but it is async and takes a moment to produce a result. I run it synchronously in mysplash activitycuz if it is acync, if there is a request to the database right after this, it returnsNotAuthorizedException.
None of the above methods worked as expected.
Also, the refresh token can be set to like 10 years, so it is not a problem at the moment, the problem is that the new access token is not being created after old one expires and I cannot do any authenticated user action.
Is there a way to quickly check if tokens are valid and if not, refresh them?
from Refresh tokens with AWS Amplify on Android
No comments:
Post a Comment