Closed
Description
[REQUIRED] Environment info
$ npx firebase --version
11.16.0
firebase-tools:
Platform:
OS X 12.6
[REQUIRED] Test case
Run a trivial HTTPS callable function in the Functions Emulator. It does not have context.auth
, as would be expected.
[REQUIRED] Steps to reproduce
Listener:
export ping = functions.https.onCall(async (params, context) => {
if (!context.auth) { throw new Error("Where's the auth?") }
console.log("Have auth", context.auth)
})
Call with functions.httpsCallable('ping')(),
[REQUIRED] Expected behavior
context.auth
have the expected credentials and output and emulator console show "Have auth" .
[REQUIRED] Actual behavior
Emulator shows "Where's the auth?"
Related:
- context.auth is undefined in callable function using emulator #2059
- context.auth is null in emulator #4690
- https://stackoverflow.com/questions/70349757/the-context-auth-works-in-cloud-but-not-when-using-the-auth-emulator-do-the-fi
Packages / upgrade
This started occurring when we updated some packages, notably:
- firebase-tools 11.6 => 11.16
- firebase 8.4 => 9.13
- firebase-admin 11.0 => 11.3
- firebase-functions 3.22 => 4.0.2
JWT Header
If we print the headers the authentication header has a proper (unsigned) Bearer
token e.g. from jwt.io
Deploy vs emulator
The function works as expected when deployed, suggesting this is an emulator problem.