Using AWS Cognito can I resolve the authenticated IdentityId given a disabled unauthenticated IdentityId?

后端 未结 1 438
太阳男子
太阳男子 2021-01-04 03:34

I have a JavaScript web application that supports Cognito unauthenticated identities. I\'m trying to figure out how to identify the linked authenticated IdentityId for a

相关标签:
1条回答
  • 2021-01-04 04:31

    I have an app that uses AWS Cognito to obtain an identity id and then possibly authenticate it. The situation is a client uses the app first as unauthenticated (guest) and then logs in using Facebook, making him/herself as authenticated, and AWS preserves the given identity ID for the authenticated user, because he is a new user. Now, the problem comes, when you log out of the app and someone else wants to use this app as unauthenticated or even authenticated. Cognito will error out saying that the access to the identity ID is forbidden, because it has already been linked to the previous user's Facebook account.

    The Cognito mobile SDKs have a way built in to handle this. They cache the identity id when using it, which is causing the issue you are seeing. When you log out, you'll want to clear that cache. I'm not sure which SDK you're using, but in iOS it's AWSCognitoIdentityProvider.clear() and CognitoCachingCredentialsProvider.clear() in Android. Similarly, if you're using Cognito Sync, there's a method in that client that will wipe the cached id and sync data.

    Also have a look at https://aws.amazon.com/blogs/mobile/understanding-amazon-cognito-authentication/

    Hope you are also following https://aws.amazon.com/blogs/mobile/using-the-amazon-cognito-credentials-provider/

    0 讨论(0)
提交回复
热议问题