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

Can I login again with Same Anonymous Account #1320

Closed
atif-infinityup opened this issue Feb 3, 2023 · 2 comments
Closed

Can I login again with Same Anonymous Account #1320

atif-infinityup opened this issue Feb 3, 2023 · 2 comments
Labels
new New issue.

Comments

@atif-infinityup
Copy link

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021.3.16
  • Firebase Unity SDK version: 9.6.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Auth
  • Other Firebase Components in use: Database
  • Additional SDKs you are using: Facebook, Admob, Bugsee
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: IOS
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

I have two Login Options.
1: Login with Google
2: Login as Guest

I am following this
https://firebase.google.com/docs/auth/unity/anonymous-auth
for login as anonymously.
On login success It creates a unique user ID (That's a correct behaviour).
But when I Logout using
auth.SignOut(); (firebase Auth method).

and then for a reason I want to login as guest again It creates new user ID all the way.
Is there anyway to get my old Authenticated data (with old USERID). Because based on this user ID I am saving some data in firebase database.
Assigning new userid always is not good for my game requirements.

Login with Google (use firebase) is good. It always return FirebaseUser with same USERID.

@atif-infinityup atif-infinityup added the new New issue. label Feb 3, 2023
@google-oss-bot
Copy link

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

@jonsimantov
Copy link
Contributor

Hi,

If you call SignInAnonymously without signing out, it will give you the same anonymous credentials as the last time, as the auth token is cached locally on the device.

If you sign out, the device will delete its locally cached credentials, so there is no way for it to get back the anonymous login. That's why you get a brand new anonymous login the next time you sign in.

I would suggest not calling auth.SignOut() when the app exits; this will leave the auth session active, even if the user is offline next time.

Note: If you are creating an anonymous account to help users store data before logging in, you may want to consider prompting them to link an auth provider (like email, Google signin, etc). This will ensure that even if they signs out, they won't lose the database items associated with their login.

@firebase firebase locked and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new New issue.
Projects
None yet
Development

No branches or pull requests

3 participants