Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to logout from amazon cognito javascript and clear cached identityId

So far I have managed to login to cognito and syncing data but am stuck at signing out users. Am able to logout from identity providers but upon login again to cognito I get an error for invalid logins. When I reload the app though it works.

like image 878
kabangi julius Avatar asked Apr 08 '15 20:04

kabangi julius


2 Answers

An issue has been created for this. The current workaround is to clear the cached id in your Cognito Credentials object, and then to re-initialize it:

cognitoCredentials.clearCachedId();
cognitoCredentials = new AWS.CognitoIdentityCredentials(cognitoParams);
AWS.config.credentials = cognitoCredentials;

Where cognitoParams is the object used to initialize the credentials, eg.:

cognitoParams = {
  IdentityPoolId: 'us-east-1:ebee2fff-acde-4382-a090-5990604a007d'
};
like image 90
JBaczuk Avatar answered Nov 06 '22 00:11

JBaczuk


After logging out from the identity providers, try calling clearCachedId() on the CognitoIdentityCredentials provider. It should look something like:

AWS.config.credentials.clearCachedId();

like image 31
Mike Murry Avatar answered Nov 06 '22 00:11

Mike Murry