Open heloineto opened 2 years ago
Any updates?
Hey! I found that snippet on "Convert an anonymous account to a permanent account". I don't know why, but the snippets on that specific page are not that great.
If you are looking into linking an anonymous account to a permanent account, it's a lot easier than you might expect. Remember that login anonymously is an Auth Provider, so you can just follow the guides located in "Link Multiple Auth Providers to an Account Using JavaScript". In my testing, you can use linkWithPopup
and linkWithRedirect
without any problem.
Now, speaking of the actual question: "Where does the "googleUser" variable come from?", I have no idea. But this issue can guide you: https://stackoverflow.com/questions/34804016/googleuser-getauthresponse-doesnt-contain-access-token As far as I saw, apparently, the googleUser variable is not related to the Firebase SDK at all.
Hope this helps.
Just realised this is a duplicate of #256
In my testing, you can use
linkWithPopup
andlinkWithRedirect
without any problem.
I'm currently using them on my app.
However, there's a bug on my app and I need the variable to be able to solve it.
The bug happens when:
A person has a Google account, "user@gmail.com"
For some reason they log out (cache is deleted, another machine, etc...), a new anonymous account is created
They proceed to use the app and make changes.
Then they try to log back on with their "user@gmail.com" account.
Right now in my app, the person will be "stuck" on the anonymous account, since I can't link an anonymous account to the existing "user@gmail.com" account.
I believe I need to be able to determine if their Google account already exists to be able to handle this situation. Either merge or delete the anonymous account.
I'm not sure about the app version of Firebase. But in Javascript, you can just catch the error and sign in the user normally. Just as the docs suggest:
I'm not sure about the app version of Firebase. But in Javascript, you can just catch the error and sign in the user normally. Just as the docs suggest
Oh, I see.
I'm not sure what past me was thinking, I guess I didn't want to prompt the user again.
It seems that's the way I'm supposed to do it. Thanks for being so helpful!
I'm not sure about the app version of Firebase. But in Javascript, you can just catch the error and sign in the user normally. Just as the docs suggest:
Hero. the docs are awful, this should be part of the linkWithX (linkWithPopup etc) doc instead of hidden like this
welp i got too excited too soon, error.credential
comes back undefined
for me RIP
I want Convert an anonymous account to a permanent account
. I have read https://firebase.google.com/docs/auth/web/anonymous-auth#convert-an-anonymous-account-to-a-permanent-account.
But I can't find how to create googleUser. Can you help me?
Where does the "googleUser" variable come from? How do i get it?
https://github.com/firebase/snippets-web/blob/509769a817d7437616bcfcb816f783b29aaca843/snippets/auth-next/index/auth_make_google_credential.js#L8-L11
The snippet of code mentions a variable called "googleUser" which has googleUser.getAuthResponse().id_token
I do not know where this variable comes from and how to get it. I've looked around the docs and internet for hours and had no luck.
This is my first issue on GitHub, I'm sorry if I'm doing it wrong.