Skip to content
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

Firebase Auth: On Google logout, sign in back to Anonymous account? #1317

Closed
JaineshPathak opened this issue Jan 20, 2023 · 6 comments
Closed
Labels
api: auth closed-by-bot needs-info Need information for the developer stale Don't have recent activity type: question

Comments

@JaineshPathak
Copy link

JaineshPathak commented Jan 20, 2023

[REQUIRED] Please fill in the following fields:
Unity editor version: 2021.3.16f1
Firebase Unity SDK version: 8.2.0
Source you installed the SDK: .unitypackage
Problematic Firebase Component: Auth
Other Firebase Components in use: Database, Remote Config, Firestore
Additional SDKs you are using: Facebook, Ironsrc
Platform you are using the Unity editor on: Windows
Platform you are targeting: Android
Scripting Runtime: IL2CPP

[REQUIRED] Please describe the question here:

Hello.

I am using anonymous account sign in when a new user installs the app and in-game currencies are stored in that account using firestore. I have given user option to login with their Google account. This works fine.

My questions are:

  1. What happens to that anonymous account when the user decides to login/logout with his Google account?
  2. Also after Google logout, is it possible to sign in back to that anonymous account so that I can retrieve the in-game currencies stored in the anonymous account? If yes how?

Thank you.

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@AlmostMatt
Copy link
Contributor

AlmostMatt commented Jan 20, 2023

You might find these pages helpful:
https://firebase.google.com/docs/auth/unity/account-linking
https://firebase.google.com/docs/auth/unity/anonymous-auth

The recommended flow is that:

  • the user is signed in with an anonymous account
  • you ask the user to authenticate with a google account (or other authentication method) to get a credential
  • while still signed into the anonymous account, call auth.CurrentUser.LinkWithCredentialAsync(credential)

The expectation is that one firebase user can have multiple associated authentication methods. It should still be the same firebase account.

Let me know if you need any more information.

@AlmostMatt AlmostMatt added type: question api: auth needs-info Need information for the developer labels Jan 20, 2023
@JaineshPathak
Copy link
Author

Thank you for replying.
If I understood correctly, LinkWithCredentialAsync() will link google account and anonymous account together, so that means Current User ID won't change and will remain the same when given by anonymous account. Correct?

What if user uninstalls the app and later decides to reinstall. He will be signed in with a new fresh anonymous account and if he tries to link his same Google account, it will be linked with the recent newly anonymous account and not old ones right?

So he won't be able to get old in-game currencies back previously stored in google account and will be overwritten by in-game currency values stored in new anonymous account.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jan 21, 2023
@AlmostMatt
Copy link
Contributor

If I understood correctly, LinkWithCredentialAsync() will link google account and anonymous account together, so that means Current User ID won't change and will remain the same when given by anonymous account. Correct?

Yes, this is correct.

What if user uninstalls the app and later decides to reinstall. He will be signed in with a new fresh anonymous account and if he tries to link his same Google account, it will be linked with the recent newly anonymous account and not old ones right?

So he won't be able to get old in-game currencies back previously stored in google account and will be overwritten by in-game currency values stored in new anonymous account.

If the user previously linked a google account to their account, then in the future they should choose to sign in using the google account instead of trying to link it again.

I'm not sure exactly what would happen if the user tried to link the same google account to multiple different accounts, but I suspect that the second attempt to link would fail.

@AlmostMatt AlmostMatt added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Jan 23, 2023
@google-oss-bot google-oss-bot added the stale Don't have recent activity label Jan 30, 2023
@google-oss-bot
Copy link

Hey @JaineshPathak. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@JaineshPathak if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: auth closed-by-bot needs-info Need information for the developer stale Don't have recent activity type: question
Projects
None yet
Development

No branches or pull requests

3 participants