Amplify-js: [RN] How to prevent federatedInfo delete on refresh token failure due to network error

Created on 27 May 2019  路  3Comments  路  Source: aws-amplify/amplify-js

Which Category is your question related to?
React-Native Amplify Auth

What AWS Services are you utilizing?
Amplify and AppSync

Provide additional details e.g. code snippets
federatedInfo is deleted from Storage after failure to refresh provider token due to network error.
Without credentials it's impossible to make AWS requests even after getting a new token.
User has to logout or restart app to get new credentials

Log
[DEBUG] 43:45.240 Credentials - refresh federated token failed Failed to sign in with Google
[DEBUG] 43:45.246 AsyncStorageCache - Remove item: key is federatedInfo
[DEBUG] 43:45.251 AWSPinpointProvider - ensure credentials error refreshing federation token failed: Failed to sign in with Google
[DEBUG] 43:45.255 AWSPinpointProvider - cannot send events without credentials, applicationId or region

Auth React Native bug needs-discussion

Most helpful comment

@manueliglesias is there any benefit of clearing the cache on failure to refresh?

I think it only makes sense when the refresh is unsuccessful due to an expired refresh token.

All 3 comments

Hi @usmansbk

This seems like a bug, and I am labeling it as such.

Seems to me that the _refreshHandlers should support some form of retry strategies to make the more resilient to network errors

https://github.com/aws-amplify/amplify-js/blob/7921668c4de1fff451ad53a4477e9ed05f0c728c/packages/core/src/Credentials.ts#L23-L24

@manueliglesias is there any benefit of clearing the cache on failure to refresh?

}).catch(e => {
logger.debug('refresh federated token failed', e);
this.clear();
return Promise.reject('refreshing federation token failed: ' + e);
});

@manueliglesias is there any benefit of clearing the cache on failure to refresh?

I think it only makes sense when the refresh is unsuccessful due to an expired refresh token.

Was this page helpful?
0 / 5 - 0 ratings