fix: Make ADC + human account work with firebase-admin - #2553
Conversation
|
Hi @foxrafa could you please take a look at the lint errors in the failing CIs? Thanks! |
|
@lahirumaramba fixed it. |
|
Oh, all of the test cases are not expecting the x-goog-user-project header. Can I change them @lahirumaramba ? |
Thanks! We also need to update the unit tests :) |
I updated them now. |
|
When will a new version with this change be released? |
|
@lahirumaramba any ETA on when this fix will be generally available? |
|
Thanks for the updating the tests! This issue will also be addressed in the credentials migration work #2466 (which I think is the proper way to address this issue). For now, I am okay with us merging this PR as a stopgap |
|
Thanks @foxrafa ! this change is now included in the |
- Picks up firebase/firebase-admin-node#2553 which unlocks using application default crendentials for local development.
Picks up firebase/firebase-admin-node#2553 which unlocks using application default credentials for local development.
Picks up firebase/firebase-admin-node#2553 which unlocks using application default credentials for local development.

This PR is intended to fix a current bug in firebase-admin.
Google Cloud recommends utilizing [Application Default Credentials (ADC)] (https://cloud.google.com/docs/authentication/application-default-credentials), however this feature does not fully work with the firebase-admin-node library when you want to utilize a human account (person@domain.com) instead of a service account.
Some GCP APIs require you to specify the quota project associated to the request, however, the current implementation of the firebase-admin-node library does not provide the project ID when making requests to GCP APIs, even if you set them through
gcloud auth application-default set-quota-project YOUR_PROJECT, because the code that handles the requests never adds the project ID to the request. And you get errors like this:Therefore, this pull request aims to fix this issue by checking if a
projectIdwas provided when calling theinitializeApp()function and adds it to thex-goog-user-projectheader of requests made to GCP APIs, just like the documentation states it should be set.This implementation is similar to how the (working) google-auth-library library handles ADC authentication (src/auth/authclient.ts:270):
This should also solve some problems described in #1377