-
Notifications
You must be signed in to change notification settings - Fork 928
Firebase Auth w/Provider: Calling getRedirectResult() always returns NULL user #3115
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
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Thanks for filing this issue! We'll look into this -- filed b/158323213 for internal tracking. |
Any updates on this issue? I am having the same problem. In a chrome browser in android the user is always null after the redirect. |
@NickNish09 is it just null after |
@samhorlbeck it happens on the
The wierd thing is that it only happens when I am using the firebase js on an Android App that is running a PWA. There are other places that the same code works |
I think I have a similar issue (if not the same). Having the problems on Android App PWA/TWA and Safari on iOS. Chrome, Firefox on iOS is working. And on desktop everything is working (also Safari). @NickNish09 Do your callback functions get called? I have tried with the following code. And it looks like the Promises do not get resolved, when the problems occur. Also I think these problems started since I have implemented ServiceWorkers. Maybe it has something to do with them, because sometimes it is working in iOS Safari. Need to check that again. console.log("calling getRedirectResult()");
firebase
.auth()
.getRedirectResult()
.then((result) => {
console.log("getRedirectResult then called", result);
})
.catch((error) => {
console.log("getRedirectResult catch called", error);
})
.finally(() => {
console.log("getRedirectResult finally called");
});
firebase.auth().onAuthStateChanged(function (user) {
console.log("firebase.auth().onAuthStateChanged", user);
});
console.log("event handlers registerd."); Edit: I have noticed that randomly locking/unlocking the screen of my iPhone (while having the page still in foreground in Safari) will cause the getRedirectResult() Promise to resolve ... |
@d03090 Actually they are being called:
The problem is that the user from I tried to run the server on my computer in production mode. This same code works. But when hitting a server on heroku (or any other server like in google cloud) it doesn't work.
|
I didn't realize this was happening in a webview / on mobile for some of you. I'm wondering if this is related to #4256 |
any solution? |
I'm having this error as well, any update? |
+1 Getting the issue here as well |
|
+1 , any updates? |
Plus one, any solutions? |
We aren't sure of the rootcause of this, but browser privacy settings could cause it. Can you try one of the mitigations in https://firebase.google.com/docs/auth/web/third-party-storage-mitigation and see if it helps? Thanks! |
I had this exact issue, tracked it down to #6827. You can confirm whether it's the same root cause by adding: window.addEventListener("beforeunload", () => {
const pendingRedirectKey = Object.keys(window.sessionStorage).find(key => /^firebase:pendingRedirect:/.test(key));
if (!pendingRedirectKey) {
console.log("firebase:pendingRedirect: key missing from sessionStorage, getRedirectResult() will return null");
}
}); Before your |
I reported this issue but I no longer work on the project, so I cannot check if any of these suggestions work. However, it does look to me as if @WestonThayer's suggestion is the most likely solution. It would be good know if people can check his solution and report back. Thanks! |
I'm facing this issue with chrome browser on IOS. |
Check out this link: https://firebase.google.com/docs/auth/web/redirect-best-practices#update-authdomain This is a known issue and it results most likely from browser settings blocking third party cookies. |
In addition to this, the fix in #6914 can also help. It is not released yet, but should be part of the next release. |
Same error with emulator as well |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Steps to reproduce:
After calling signInWithRedirect() and then getRedirectResults() on the page load after the login succeeds, the user is always null.
This has been reported before here but was closed.
Relevant Code:
This code runs on page load, but the user is null:
However, in onAuthStateChanged there is a user.
https://stackoverflow.com/questions/62032646/firebase-realtime-database-rules-to-restrict-on-user-id-runs-in-simulator-but-no/62040506#62040506
The text was updated successfully, but these errors were encountered: