I am trying to auth using emulator with a firebase custom token sent from functions to a web page.
But it returns a HTTP400 from www.googleapis.com
when i use it with signInWithCustomToken();
.
/** BACKEND SIDE **/
const token = await createFirebaseToken(userid);
res.status(200).send(token);
/** FRONTEND SIDE **/
const res = await axios.post(endpoints.signin,{/* oauth data*/});
await document.fApp.auth().signInWithCustomToken(res.data); /* HTTP400 here */
The custom token is decoded as below:
{
"https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat": 1605605206,
"exp": 1605608806,
"iss": "firebase-auth-emulator@example.com",
"sub": "firebase-auth-emulator@example.com",
"uid": *userid*
}
Is it supposed to send to googleapis.com rather than the local emulator?
I did set firebase web config with authDomain:"localhost:9099"
, and used powershell env to point GOOGLE_APPLICATION_CREDENTIALS
to a service-account.json, throw me a warn on startup though:
Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to ***. Non-emulated services will access production using these credentials. Be careful!
Get also this warn 3 times when i call admin.auth().createUser()
, dunno if that's related:
Received service account token strange token not from service-account.json Assuming that it owns project *** my project-id ***
Forgot to set
firebase.auth().useEmulator('http://localhost:9099');
as stated in the documentation.
Now customToken are sent to the emulator.