Firebase tools: login as service account

Viewed 8547

I cannot find way how to deploy firebase project (functions) on behalf of service account.

Nothing is said both on documentation page and also I found nothing related in their bug tracker.

As described, I run firebase login:ci command but then I need to login myself - and I want login as service account.

Such feature is available using gcloud tool, but, as stated in docs,

Cloud Functions written using the Firebase SDK for Cloud Functions can't be deployed using the gcloud command-line tool, and vice-versa.

3 Answers

This works:

$> gcloud iam service-accounts keys create ./secrets.json --iam-account=<SERVICE_ACCOUNT_EMAIL>

$> export GOOGLE_APPLICATION_CREDENTIALS="./secrets.json"

$> firebase deploy --project <PROJECT_ID>

You can actually use the refresh token of a Google account (service account or otherwise) that has access to Firebase roles, and set it to the FIREBASE_TOKEN environment variable.

For example I use Cloud Build (which has an associated service account that is already logged into gcloud) and then set FIREBASE_TOKEN to the output of gcloud auth application-default print-access-token.

Related