Skip to content

[Question][Auth] Can FirebaseAuth.CurrentUser be initialized from an existing ID token + refresh token? #1504

Description

@qomo-wq

What is your question?

I want to know whether the Firebase Unity SDK has any supported way to initialize FirebaseAuth.CurrentUser from an already-issued Firebase Auth session.

My intended flow is:

  1. My trusted backend uses Firebase Admin SDK to create a custom token.
  2. My backend calls the Identity Toolkit signInWithCustomToken endpoint.
  3. The backend receives the Firebase ID token, refresh token, and expiration.
  4. The backend returns that session information to the Unity client.
  5. I want FirebaseAuth in Unity to adopt that session so FirebaseAuth.CurrentUser is populated and Firebase services such as Firestore continue working normally.

I specifically want to avoid calling SignInWithCustomTokenAsync() from the Unity client, because the custom-token exchange and future Secure Token refreshes would be handled by my backend.

Is there currently any supported API in the Firebase Unity SDK to initialize/hydrate FirebaseAuth from:

  • ID token
  • refresh token
  • expiration time

If not, is there another supported way to achieve this while keeping FirebaseAuth.CurrentUser and direct Firestore SDK access working normally?

Why I am asking for this?
The reason for this architecture is that I am investigating using VPC Service Controls to restrict direct client access to identitytoolkit.googleapis.com and securetoken.googleapis.com, while allowing only my trusted backend to access those endpoints. If that architecture is viable, I would need Unity Firebase Auth to adopt the ID token + refresh token returned by my backend without calling those Auth endpoints directly.

Firebase Unity SDK Version

13.9.0

Unity editor version

6000.4.0f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

No response

Other Firebase Component(s) in use

No response

Additional SDKs you are using

No response

Targeted Platform(s)

Android, Apple Platforms

Unity editor platform

Mac

Scripting Runtime

IL2CPP

Release Distribution Type

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions