-
Notifications
You must be signed in to change notification settings - Fork 271
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
isAuthenticated is false after successful login #82
Comments
Check that you aren't preventing sameSite cookies in your browser. Anything based on Chromium will automatically block sameSIte cookies, which prevents the user session cookie from being saved. |
Hi; I'm doing similar and also getting |
I am also experiencing the similar problem in which the |
Hi @Kaschman - could you check if your If it doesn't work, please share your |
Hi all! I dont know if this is related, but I found a bug when you are logged and the isLoading variable is set as false but isAuthenticated variable is false too for 2 or 3 seconds so when you check if isAuthenticated it always gets false the first time. I think the problem is that the isAuthenticated default value is set as FALSE, so the first time we ask for it, it returns that value. I made some changes to my local files and set the initial value as null, so if I get a null I know the reducer still didn't update the value and that I have to wait until the value change to false or true to let (or not) the user enter to a specific page. |
Hi @Dummote - thanks for your input
Would you mind sharing a minimal test case code example of what you're describing? |
Yes! If you try to do something like this:
When you enter that page, you are going to have the isLoading in TRUE and the isAuthenticated in FALSE (but the isAuthenticated is not really false because you have not check it yet), the problem is in one point you are going to have the isLoading and the isAuthenticated in FALSE so if going to redirect you to the login again and again. This happends when you are logout and use that code. If you remove the loginWithRedirect and put two console log in there your are going to have a result like this
I also try avoid listening the isLoading in the useEffect, and have the same result
|
@adamjmcgrath - |
@adamjmcgrath on further investigation - I'm using react router 4, and adding the callback as instructed (around https://auth0.com/blog/complete-guide-to-react-user-authentication/
|
@adamjmcgrath I've managed to get it to work on CRA when I redirect them back to |
@anthonycole Thanks for sharing your investigation. I pretty much followed the tutorial in the https://auth0.com/blog/complete-guide-to-react-user-authentication blog article as well, except that I set the Here is the reference to the Actually it didn't occur to me that redirecting the authenticated user back to the |
This thread is taking a few tangents, and I haven't heard from @Kaschman for a while, so I'm going to close it (@Kaschman feel free to reopen if you want to share some more details) @Dummote - I'm not able to reproduce what you're seeing, if you want me to investigate, please could you open a separate issue with a running example, or a link to some code that I can run. @anthonycole and @jimmyzhen - it sounds like your issues are resolved - please open a new issue with some reproducible steps if this is not the case. |
@adamjmcgrath I don't think our issues have been resolved... |
One thing which I discovered causes this: In order for isAuthenticated to get set to true, the function in onRedirectCallback has to get called. I had my redirectUri set to "http://localhost:3000". However, I was redirecting on "/" to "/some-other-page". In other words, the redirectUri was being navigated away from. Apparently, if the redirectUri doesn't get a complete load, the onRedirectCallback fn doesn't get called. I solved in by creating a dedicated /auth-callback page and set this to the redirectUri. |
I am still having this issue even after I changed my callback url to http://localhost:3000/dashboard and set it like so
|
Hi, thanks for your explanation. I'm curious to see how you did this, probably with some example code. I'm stuck on peoboem in this issue but i have no clue on how to solve it using your method. Please advise, thanks |
If anyone else is having this issue - my problem was caused by the Auth0 Provider being outside of my BrowserRouter. This caused weird things to happen with calling history.push/history.replace. I solved it by moving my BrowserRouter inside my Auth0 Provider. |
Can you provide an example? I'm also struggling to get the |
Auth0 Provider outside of BrowserRouter solved with Auth0 Provider outside of BrowserRouter ? |
I have the same problem. It is implemented in Nextjs <Auth0Provider
redirectUri="http://localhost:3000/"
onRedirectCallback={(appState) => {
Router.replace('/')
}}>... If you define a custom In the following cases, it will not occur. <Auth0Provider
redirectUri="http://localhost:3000/"
>... |
Sorry. Now, it is working as intended. If I define the function used in const onRedirectCallback = (appState?: AppState) => {
Router.replace(appState?.returnTo || '/')
}
const App: FC<AppProps> = (props) => {
return (
<Auth0Provider
onRedirectCallback={onRedirectCallback}>... |
Further to this, I was hosting my statically generated site on S3, using
|
I found another thing which will cause this is if there is an error thrown in your |
In react router const onRedirectCallback = (appState) => navigate(appState?.returnTo || window.location.pathname); It made things working on my side. |
this seems like a bug in the underlying auth0-spa-js since i'm getting the same problem in Angular with LoginWithPopup: here's a simple repo login(): void { This shows that isAuthenticated$ gets its True value during the same Tick, but alas, our callback has already run in the same Tick also, unless we add delay(0) |
I was having this problem with Auth0-React in Chrome Incognito/Safari. What fixed it for me was explicitly setting the |
I had a similar implementation of the callback function, but still face the same problem. Making the callback function async resolved the problem in my application.
|
Hey guys, I found there is a tip here that said
I am developing a React App with vite. After these steps, it works for me: |
@hecool108 - Thank you so much for this, I've been trying to resolve this for 2 days now and I've tried EVERYTHING on the internet. 😄 This solved it for me for my React/Vite app. Even though in the "Credentials" section the Authentication Methods SEEMED to be set to "None", it was not until I clicked on the already set "None" word and saved it (there was in fact no change, but the save button got enabled), and this fixed it. This seems like a bug on the Auth0 platform. |
I have fixed this issue on "@auth0/auth0-react": "^2.1.1", with redirectUri. I'm trying to login from /login route on react. So, I added http://localhost:3000/login in Allowed Callback Urls. After this, I fixed my redirectUri with http://localhost:3000/login.
|
|
This was my issue as well. Auth0 redirected to '/' and in my app I have logic in the router that redirects to a specific page on load. I added a root path and only redirect when the user is authenticated. |
After following the SPA setup guide I have similar problems to #49 #60 and #63.
The fix of cycling Application type is not working for me. I have also tried to enable refresh tokens as mentioned in #60 but see the same results.
I see 'Success Login' events in my User History and see populated
code
fields in my callback urls. ButisAuthenticated
remains false.I have tried to get the CRA example app found in this repo running with my app credentials but am struggling to get the npm dependencies installed correctly to the point where the example app will start.
Any further troubleshooting ideas? Should I try the older client JS library?
The text was updated successfully, but these errors were encountered: