I need to authenticate a Firebase user with node so that I can test some methods on the server side. For each secure request, I check the Firebase token using:
firebase.auth().verifyIdToken(firebaseAccessToken).then(function(decodedToken) {
So, in my test, I created a token with uid from the Firebase database
firebase.auth().createCustomToken(uid).then(function(token) {
Later I read that user tokens are not verified by the verifyIdToken method, only generated by the client.
I looked at this answer - server side token check in firebase
So I added databaseAuthVariableOverride to init json
firebase.initializeApp({ credential: firebase.credential.cert(serviceAccount), databaseURL: [dbURL], databaseAuthVariableOverride: { uid: [uid] } });
Still getting output in my tests
Error: expected 200 "OK", got 401 "Unauthorized"
And the firebase error is -
Error: Decoding Firebase ID token failed. Make sure you passed the entire string JWT which represents an ID token. See https:
So how do I emulate a user with my current setting?
source share