[DOC] Improve documentation for service account impersonation
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- gcp, nodejs, typescript
- Domain
- authentication, cloud, documentation
Research direction
Start with the reported gcloud auth application-default login --impersonate-service-account flow and the application_default_credentials.json format, then compare it with the initializeApp, cert, and applicationDefault examples. Document a working local-development example for firebase-admin v13.0.1, including the required permission setup and what successful authentication looks like.
Written by the indexing model from the issue text.
Description
It seems like service account impersonation is the recommended way to authenticate for local development.
But it's not very clear how this is done in practice. Do I need to adapt my code for this?
I've run:
gcloud auth application-default login --impersonate-service-account SERVICE_ACCT_EMAIL
and I have a token in:
cat /Users/myuser/.config/gcloud/application_default_credentials.json
{
"delegates": [],
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/myserviceaccount@myproject.iam.gserviceaccount.com:generateAccessToken",
"source_credentials": {
"account": "",
"client_id": "removed",
"client_secret": "removed",
"refresh_token": "removed",
"type": "authorized_user",
"universe_domain": "googleapis.com"
},
"type": "impersonated_service_account"
}
I have tried code like this (after having looked at #2800):
initializeApp({
storageBucket: config.firebase.storageBucket,
credential: cert(process.env['GOOGLE_APPLICATION_CREDENTIALS']),
projectId: config.firebase.projectId,
})
But then I got an error:
FirebaseAppError: Failed to parse service account json file: Error: Service account object must contain a string "project_id" property.
and this, I assumed this would pick up the ADC credentials file, notice its impersonation, and things would just work:
initializeApp({
storageBucket: config.firebase.storageBucket,
credential: applicationDefault(),
projectId: config.firebase.projectId,
})
But then I got this error:
"Getting metadata from plugin failed with error: Could not refresh access token: PERMISSION_DENIED: unable to impersonate: Permission 'iam.serviceAccounts.getAccessToken' denied on resource (or it may not exist).",
My local user has the Owner role in the GCP project. And has owner permissions on the service account. The service account has the Service Account Token Creator role.
Im using firebase-admin v13.0.1
Some working sample code for this would be very helpful.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 419
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 16
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-admin-node
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 comments · 1 assignee ·
-
api: messaging
Difficulty 3/5 1-2 days Newbie friendliness 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
Difficulty 5/5 Over a week Newbie friendliness 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 comment · 1 assignee ·
All issues in firebase/firebase-admin-node
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
AOSSIE-Org/DebateAI#582 · 2 comments ·