Amplify-js: Local storage is missing an ID Token, Please authenticate

Created on 7 Oct 2018  路  11Comments  路  Source: aws-amplify/amplify-js

* Which Category is your question related to? *
Authentication

* What AWS Services are you utilizing? *
Cognito

* Provide additional details e.g. code snippets *
I am using Amplify within Angular 6. Before Angular 6, I was using a much older version of Amplify that didn't support much more than Cognito with Angular 5 and this workflow worked just fine. I keep seeing this error message reported all over the place when I google it, but I can't seem to find what the proper resolution is.

When I call Auth().signIn(), I get a cognitoUser back and can see all the details when I output the object to the console

Next when I then try passing the user to Auth().userAttributes(), it causes this error.

"Local storage is missing an ID Token, Please authenticate"

What is the actual cause of this, is there extra configuration that has to be done that I'm not aware of? My config is setup as follows:

{
      "Auth": {
        "region": "us-east-1",
        "userPoolId": "us-east-*******",
        "identityPoolId": "us-east-1:***************************",
        "userPoolWebClientId": "*****************************"
      }
    }

Do I need anything additional in either the config or in code to get this back up and running?

Auth investigating pending-close-response-required

Most helpful comment

I am having the same problem as dguisinger.

After Auth.signIn() returns the User object but tokens are not found in browser's localStorage.
Also like dguisinger, the state of my testuser account is 'requireNewPassword' as it is created in the AWS Console for Cognito by admin. This may be a factor.
calling Auth.userAttributes will produce same error trace as above.

I am using Ionic 3 & Angular 5.

Can we escalate this problem? Thank you.

All 11 comments

Additional information.
I have sat here trying to find a way to resolve this,and have been walking through the AWS Amplify code in a debugger.

I have found StorageHelper appears to be working. When it starts up, it gets the window.localStorage object, and then sets a test value and removes it. I can verify that the item is added and removed from local storage.

I have found that when this.storage.getItem(idTokenKey) is called, there is no item stored...
I haven't been able to find where you actually store this key, or how it gets triggered...

The user returned after signin is in "requireNewPassword" state. The user was created in the cognito userpool after tweaking my user pool settings, and needs a new password.

I am assuming the password needs to be created in order and that it isn't storing into localStorage if the user is in this state, because the user isn't fully signed in...

So I tried to manually change the password in code if I get that status...
Except that doesn't work either.

Error: Local storage is missing an ID Token, Please authenticate
    at CognitoUser.getSession (CognitoUser.js:1175)
    at Auth.js:1072
    at new ZoneAwarePromise (zone.js:891)
    at AuthClass.push../node_modules/@aws-amplify/auth/lib/Auth.js.AuthClass.userSession (Auth.js:1070)
    at Auth.js:1294
    at new ZoneAwarePromise (zone.js:891)
    at AuthClass.push../node_modules/@aws-amplify/auth/lib/Auth.js.AuthClass.changePassword (Auth.js:1293)

I am having the same problem as dguisinger.

After Auth.signIn() returns the User object but tokens are not found in browser's localStorage.
Also like dguisinger, the state of my testuser account is 'requireNewPassword' as it is created in the AWS Console for Cognito by admin. This may be a factor.
calling Auth.userAttributes will produce same error trace as above.

I am using Ionic 3 & Angular 5.

Can we escalate this problem? Thank you.

I'm having this problem as well... any resolution?

You guys need to use the completeNewPassword method instead of changePassword. This will actually complete the auth challenge presented by the API.

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.

@tqhoughton you really helped me with the recommendation to use completeNewPassword.

Per the original question from @dguisinger I am also attempting to create user credentials with pre-defined passwords. Is there any way to avoid the password challenge on these types of accounts?

I would prefer to set the credentials upon account creation and then not provide a UI for passwords to be overridden. Is the pattern I'm describing possible with Cognito?

I don't believe that pattern is possible. All users created through adminCreateUser must change their password as part of the auth flow or they will remain in the COMPLETE_NEW_PASSWORD state.

I am having the same issue. After running .completeNewPassword with the user, comes the error:

InvalidParameterException

Still having the same issue.

guys, any update? i am having the same issue too

Was this page helpful?
0 / 5 - 0 ratings