ResourceNotFoundException after deleting anonymous identity from Cognito.
See original GitHub issueMy Expo/React Native app supports both signed-in and anonymous users. I have this code to get the user’s IdentityId:
const userCredentials = await Auth.currentUserCredentials();
const id = userCredentials.data.IdentityId;
let name = "anonymous";
if (userCredentials.authenticated) {
const userInfo = await Auth.currentUserInfo();
name = userInfo.attributes.email;
}
This works fine and I’ve been using it to test my Expo app (expo v31.0.4) on the iOS Simulator. So here are the steps that caused the problem:
- Open a browser and login to AWS.
- Go to Cognito/Manage Identity Pools.
- Select your identity pool.
- Click the “Identity browser” menu item on the left.
- Select the anonymous user with the same ID created by the iOS Simulator.
- Click the “Delete identity” button on that page.
So I deleted the identity, but in theory this shouldn’t be an issue. It’s just the anonymous identity – my expectation is that Amplify will just recreate it if it doesn’t exist. But it doesn’t. Instead the above code throws an exception when I call Auth.currentUserCredentials():
ResourceNotFoundException: Identity ‘us-west-2:b3149f7c-57a8-480b-a97d-95e6582ca370’ not found.
Here are some [DEBUG] lines:
[DEBUG] 29:20.721 AuthClass - Getting current user credentials
[DEBUG] 29:20.722 AuthClass - failed to get or parse item aws-amplify-federatedInfo SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at AuthClass.currentUserCredentials (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:183830:30)
at App.componentWillMount$ (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:144677:68)
at tryCatch (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:21886:19)
at Generator.invoke [as _invoke] (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:22061:24)
at Generator.prototype.(anonymous function) [as next] (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:21929:23)
at tryCatch (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:21886:19)
at invoke (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:21962:22)
at blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:21992:13
at tryCallTwo (blob:http://127.0.0.1:19001/ff59e96d-d7ba-48a6-8508-2a1cc23b2bbd:4209:7)
[DEBUG] 29:20.727 AuthClass - Getting current session
[DEBUG] 29:22.443 AuthClass - Failed to get user from user pool
[DEBUG] 29:22.446 AuthClass - Failed to get the current user No current user
[DEBUG] 29:22.449 AuthClass - getting session failed No current user
[DEBUG] 29:22.451 Credentials - setting credentials for guest
[DEBUG] 29:22.802 Credentials - Failed to load credentials
[DEBUG] 29:22.819 Credentials - Failed to load credentials CognitoIdentityCredentials {expired: true, expireTime: null, accessKeyId: undefined, sessionToken: undefined, params: {…}, …}
[DEBUG] 21:22.195 AWSPinpointProvider - ensure credentials error Error: Identity 'us-west-2:b3149f7c-57a8-480b-a97d-95e6582ca370' not found.
at Request.extractError (aws-sdk-core-react-native.js:1854)
at Request.callListeners (aws-sdk-core-react-native.js:3610)
at Request.emit (aws-sdk-core-react-native.js:3582)
at Request.emit (aws-sdk-core-react-native.js:7723)
at Request.transition (aws-sdk-core-react-native.js:7062)
at AcceptorStateMachine.runTo (aws-sdk-core-react-native.js:7867)
at aws-sdk-core-react-native.js:7879
at Request.<anonymous> (aws-sdk-core-react-native.js:7078)
at Request.<anonymous> (aws-sdk-core-react-native.js:7725)
at Request.callListeners (aws-sdk-core-react-native.js:3620)
[DEBUG] 29:22.826 AWSPinpointProvider - cannot send events without credentials, applicationId or region
What’s the solution to this problem?
Thanks, Alvaro
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
AWS Cognito - Why does changing my bundle id cause a ...
Now I am getting a ResourceNotFoundException when trying to download that file. The exception references an identity id not Naturally I ...
Read more >DeleteIdentityPool - Amazon Cognito Federated Identities
Thrown when a user is not authorized to access the requested resource. HTTP Status Code: 400. ResourceNotFoundException. Thrown when the requested resource (for ......
Read more >CognitoIdentityProvider — Boto3 Docs 1.26.36 documentation
A low-level client representing Amazon Cognito Identity Provider ... The user pool ID for the user pool where you want to delete user...
Read more >Use an existing Cognito User Pool and Identity Pool
Select the "Cognito User Pool only" option when you've run amplify import auth . In order to successfully import your User Pool, your...
Read more >aws cognito-sync - Fig.io
describe-dataset, Gets meta data about a dataset by identity and dataset name. With Amazon Cognito Sync, each identity has access only to its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alvaro1728 - Thanks for digging into this. I’m marking this as a bug and we are investigating further.
If you manage to run into this, adding
await Auth._storage.clear()
before any auth code did the trick for me! I was creating/deleting Cognito users for testing purposes and forgot to log out before I deleted the user 😅