Skip to content

[Question] Auth not working in Unity editor #1098

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

Closed
zxt385189207 opened this issue Aug 30, 2024 · 10 comments
Closed

[Question] Auth not working in Unity editor #1098

zxt385189207 opened this issue Aug 30, 2024 · 10 comments

Comments

@zxt385189207
Copy link

What is your question?

Unable to signin properly in the unity editor environment, but can sginin and upload and download files on my Android phone.

FirebaseException: An internal error has occurred.

I don't know where the setup caused this problem and I can't test the functionality in the unity editor.

Something like that firebase/firebase-cpp-sdk#10 , I wrote a simple demo with no other SDK.

I need help, please.

Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Verbose;
Added app name=__FIRAPP_DEFAULT: options, api_key=..., app_id=....., database_url=, messaging_sender_id=....., storage_bucket=test-xxxx.appspot.com, project_id=test-xxxx (0x01788e20)
UnityEngine.Debug:Log (object)

Creating Auth ..... for App ....
UnityEngine.Debug:Log (object)

Cloud Storage gs://test-xxxxxx.appspot.com: Created __FIRAPP_DEFAULTgs://test-xxxxx.appspot.com
UnityEngine.Debug:Log (object)

LoadUserData: Credential com.xxxx.xxxx.test-xxxx.firebase.auth/__FIRAPP_DEFAULT[0] not found
UnityEngine.Debug:Log (object)

Failed to read user data for app (__FIRAPP_DEFAULT).  This could happen if the current user doesn't have access to the keystore, the keystore has been corrupted or the app intentionally deleted the stored data.
UnityEngine.Debug:Log (object)

DeleteUserData: Credential com.xxxx.xxxx.test-xxxx.firebase.auth/__FIRAPP_DEFAULT[0] not found
UnityEngine.Debug:Log (object)

Firebase Unity SDK Version

11.6.0 and 12.2.0

Unity editor version

2021.3.12f1

Installation Method

Unity Package Manager

Problematic Firebase Component(s)

Authentication

Other Firebase Component(s) in use

Storage

Additional SDKs you are using

No response

Targeted Platform(s)

Desktop

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@zxt385189207 zxt385189207 changed the title [Question] [Question] Auth not working in Unity editor Aug 30, 2024
@argzdev
Copy link

argzdev commented Aug 30, 2024

Thanks for reaching out, @zxt385189207. There was also a similar issue filed before #1048 regarding Auth login. Did you recently change or restrict the API access? This could have triggered the issue.

@argzdev argzdev added the needs-info Need information for the developer label Aug 30, 2024
@zxt385189207
Copy link
Author

Thanks for reaching out, @zxt385189207. There was also a similar issue filed before #1048 regarding Auth login. Did you recently change or restrict the API access? This could have triggered the issue.

I did not impose any restrictions, or is it possible that Firebase has default settings?

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Aug 31, 2024
@zxt385189207
Copy link
Author

By the way, on another computer the same project printed USE_AUTH_EMULATOR not set.

@zxt385189207
Copy link
Author

zxt385189207 commented Sep 1, 2024

https://github.com/firebase/firebase-unity-sdk/tree/main/auth/testapp

  1. No additional code was added.
  2. The Auth package was imported.
  3. The google-services.json file was imported, and google-services-desktop.json was automatically generated.
  4. Clicked unity play.
  5. click SigninAnonymouslyAsync Button

image

  1. quit Unity

QQ_1725199175453

With this code, turning off UNITYEDITOR can wait indefinitely.
So What's the problem?

@argzdev
Copy link

argzdev commented Sep 2, 2024

Sorry, I'm not sure what the issue is. I'm unable to reproduce the same behavior on my side. You mentioned that the issue is also reproducible on another computer, I wonder if the issue is the google-services.json. Could you try using a different Firebase project and see if the same behavior is encountered?

Also any chance you can share an MCVE? Please remove any PII (personally identifiable information). This'll help us speed up the investigation. Thanks!

@argzdev argzdev added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Sep 2, 2024
@zxt385189207
Copy link
Author

zxt385189207 commented Sep 2, 2024

@argzdev

I think it might be a network issue. I created two projects and tried using different google-services.json files, but the result was the same. I'm a Unity developer in China, and I’m affected by the VPN. It seems that most developers don’t debug code or test in the Unity Editor, but rather on an emulator or real device. This issue seems to be quite rare. It's possible that if I send an MCVE, it might work fine in your network environment. I'm currently using the official Auth sample code.

I encountered the following error:

Failed to read user data for app (__FIRAPP_DEFAULT). This could happen if the current user doesn't have access to the keystore, the keystore has been corrupted or the app intentionally deleted the stored data.
UnityEngine.Debug:Log (object)

In what situations does this error occur, and how can the client determine whether the issue is related to the network or the google-services.json ?

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Sep 2, 2024
@argzdev
Copy link

argzdev commented Sep 3, 2024

Thanks for the additional information, @zxt385189207. You're right, given that you're using the official Auth sample code, the MCVE will most likely work on our side as well. After further discussing this with our engineers, we came to the conclusion that the issue is due to the network restriction and not related to the google-services.json.

In what situations does this error occur, and how can the client determine whether the issue is related to the network or the google-services.json ?

I thought it could be due to a specific Firebase Project API restriction, which is why I considered changing the google-services.json to another project which might cause a different behavior, but this doesn't seem to be the case. And now, it most certainly is due to a network restriction.

Unfortunately there's not much we can do here, since it looks like everything is working as intended on the SDK side. Network restrictions are out of our control. That said, I'll go ahead and close this thread. If you'd like to know more regarding these restrictions in relation to China, feel free to reach out to our Firebase support for more guidance.

@argzdev argzdev closed this as completed Sep 3, 2024
@argzdev argzdev removed the needs-attention Need Googler's attention label Sep 3, 2024
@zxt385189207
Copy link
Author

Can a proxy setting be added to network requests made by the Firebase SDK in Unity? @argzdev

@argzdev
Copy link

argzdev commented Sep 4, 2024

Sorry, you'll likely need to reach out to our Firebase support for more guidance regarding network connections.

@firebase firebase locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants