Uh oh!
There was an error while loading. Please reload this page.
fix: Make ADC + human account work with firebase-admin - #2553
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
lahirumaramba
commented
May 14, 2024
Hi @foxrafa could you please take a look at the lint errors in the failing CIs? Thanks! |
foxrafa
commented
May 14, 2024
@lahirumaramba fixed it. |
foxrafa
commented
May 14, 2024
Oh, all of the test cases are not expecting the x-goog-user-project header. Can I change them @lahirumaramba ? |
lahirumaramba
commented
May 14, 2024
Thanks! We also need to update the unit tests :) |
foxrafa
commented
May 14, 2024
I updated them now. |
rogsilva
commented
May 24, 2024
When will a new version with this change be released? |
foxrafa
commented
Jun 2, 2024
@lahirumaramba any ETA on when this fix will be generally available? |
lahirumaramba
commented
Jun 18, 2024
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 |
lahirumaramba
commented
Jun 20, 2024
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.
erlichmen
commented
Jun 25, 2024
This fixes so much pain, thank you for that. |
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