-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth.currentAuthenticatedUser() always return "Not Authenticated" causing Infinite reloads #5167
Comments
see #4420. if doesn't help, please provide your amplify-js version |
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems. |
Same for me, can't bring the user data, the error message it's probably wrong as well "aws-amplify": "^3.0.5", |
Why this issue has been closed? Is there any update on this issue? I am also facing same issue. |
"aws-amplify": "^3.0.16", Same problem, this needs to be reopened. |
please reopen this issue. Was anyone able to solve it? |
I'm looking for a solution too |
Can't figure this out either. Happens on the browser. I literally call: const user = await Auth.signIn(email, password);
console.log(user); // ✅ is correct
const response = await Auth.currentAuthenticatedUser();
// 🚫 throws 'not authenticated' |
To make sure the user is actually full authenticated:
There you will see the list of users with the email verified or not, remember the user is full verified once they have entered the verification code sent by email |
After you sign up a user, I believe you need to also sign in. For example:
|
I'm facing the same problem, here. Did anyone find a solution? {
"amazon-cognito-identity-js": "^4.3.5",
"aws-amplify": "^3.0.24",
"aws-amplify-react-native": "^4.2.5",
"react": "16.11.0",
"react-native": "0.62.2"
} |
We are also facing this issue. I'm 99% sure this is some sort of botched localStorage lookup because |
I'm having this issue as as well, in my case i created the user using |
I am also facing this issue. For my react routes, I am checking the authentication and it always returns not authenticated. |
@kvdy Maybe you are missing the confirmation step? Auth.confirmSignUp |
In my case I had MFA turned on and the Auth module was waiting for OTP. I made MFA optional for my user pool and all went OK |
I'm also facing this issue, I'm using React and it returns "not Authenticated" everytime. I am manually creating users in the user pool and marking the email as "verified" and I still encounter the problem. Is there a solution? |
Also facing the same issue. User is verified and confirmed. I can see that in the developer tool, amplify is sending proper code challenge and getting access token in return. The problem is, as the @TheDutchCoder said, user data is not getting persisted in the storage. Further debugging shows that the |
I remembered that this infinite reload might happen if the user you are using is not "confirmed" using the phone or email code |
I was getting similar errors using a Cognito pool configured with an ADFS identity provider and amplify-3.8.8. I was able to get it working with the following config: When using a custom identity provider - i.e. not one of the pre-baked Additionally, ensure the
The Cognito user pool setup section of the docs has an example of appending to the config. See also this SO question |
I have the same issue. I'm using nextjs and cookies - aws-cognito-next returns the current authenticated user and this library's currentAuthenticatedUser does not. I'm calling them in the same function too. Every part of the auth flow works as expected (sign up, confrim, forgot pw, change pw, etc) except the actual login. |
same bug here, has this been solved? Last time I have used it was working |
Mine is working now. For me my issues were the following. Client side can configure with either
or
However, on server side the former did not work for me. Server side you have to configure from the default export.
or you can still use the following after you configure with the latter default export.
Also, make sure your user is verified. If you use cookies make sure your exp is a number and not a string. I was pulling it from an env var and not converting it to a number. Also, in nextjs specifically, you must call configure Lastly, when possible I'd try to use |
For me it's fine on the web react project. But in expo (react-native) when i call
Same setup works fine for web, I've tested with Facebook and Google auth. Normal email sign in, sign up works absolutely fine. |
with SignInWithApple undefined all the time! only Facebook and google works! :( |
I was having the same issue and came across this: Basically, after signIn if the user has a challenge of 'NEW_PASSWORD_REQUIRED', the same problem that @janhesters was having repeats:
I've used this:
After this, I confirmed that my Hub was receiving the
and with that, I was finally authenticated to make all the requests I needed, like
This problem existed for me because I created these test users in the Cognito UI, which created a 1-time password on those accounts. |
I dont know if it can help or not someone. In my case I had |
This problem is because our first users has status NEW_PASSWORD_REQUIRED, we need to change this password Running this command on your terminal Note: you can to find the --user-pool-id on Aws console > Cognito > Users > General Settings🥸 |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
** Which Category is your question related to? **
Correct implementation of Auth.currentAuthenticatedUser()
** What AWS Services are you utilizing? **
Cognito
** Provide additional details e.g. code snippets **
I have a use-case wherein, I first want to check if a user is authenticated or not on the first visit to the site. If the user is not authenticated, I want to redirect the user to the OIDC provider configured at Cognito using Auth.federatedSignIn(). However, I am getting "Not Authenticated" response from the Auth.currentAuthenticatedUser() everything.
This is the function calling Auth.currentAuthenticatedUser():
Now, from the component, I am calling getCurrentUser()
The events I am getting in the console:
The page is getting refreshed again and again.
The text was updated successfully, but these errors were encountered: