Describe the bug
If federated token refresh fails due to a network error, auth resets requiring the user to manually sign in again. Since token refreshing hasn't failed due to _rejection_ by the identity provider the refresh token _may_ still be valid and can still be used once internet access is restored.
I'm using Auth0 as my federated auth provider.
To Reproduce
Steps to reproduce the behavior:
I perform the following in a React Native app running in the iOS simulator.
From this point on the API client calls reject with "Missing Authentication Token". In the scenario described here token refreshing has failed because of a network problem, not because my identity provider (auth0) as rejected the refresh request. I feel this type of error should be treated differently from a _"identity provided responded and refused to refresh the token"_ type error.
Expected behavior
If token refreshing is not possible because of a network error the API client shouldn't clear/reset the current federated sign in. This is particularly important in React Native as network access could be intermittent.
The documentation for handling federated auth needs a lot of work and should better explain how the API client behaves if token refreshing has failed.
@willdady I might need more details of this issue so I can reproduce it. Are you using Auth0 federated with Cognito Federated Identity Pool and using Auth.federatedSignIn() to login? Are you using Authenticator or withAuthenticator in your react-native app? Do you use the AWS Pinpoint?
Are you using Auth0 federated with Cognito Federated Identity Pool and using Auth.federatedSignIn() to login?
Yes
Are you using Authenticator or withAuthenticator in your react-native app?
No
Do you use the AWS Pinpoint?
No
@willdady also are you calling Auth.currentCredentials() when the app is loaded? Can you describe a little more around what do you do when the app is loaded?
@powerful23 once the app launches my initial components triggers various API requests to API Gateway using the API client provided by Amplify. I don't call Auth.currentCredentials(). I am working on the assumption that Amplify _just works_ and knows how to deal with intermittent network access.
As described above I think there needs to be a better way of dealing with the case where the refreshHandlers fail because of lack of internet access.
@willdady Did you find a way to resolve this problem. I believe i'm having the same issue. AWS deletes my credentials after starting up app without network connection.
@usmansbk No it's an ongoing issue
Seems related to https://github.com/aws-amplify/amplify-js/issues/3349
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
Is there any update to it? Did you find a solution or workaround @willdady ?
I believe so. We still have several issues with Amplify on React Native.
Tell me about it, well perhaps not the issues (I have many of my own :D) but perhaps the workaround? I'd be super interested to know how you handle all the network errors.
Is there any update?
Most helpful comment
@powerful23 once the app launches my initial components triggers various API requests to API Gateway using the API client provided by Amplify. I don't call
Auth.currentCredentials(). I am working on the assumption that Amplify _just works_ and knows how to deal with intermittent network access.As described above I think there needs to be a better way of dealing with the case where the
refreshHandlersfail because of lack of internet access.