TLDR; I'm having trouble assigning an IAM permission to a service account.
I'm building a test that involves minting custom tokens with firebase Auth. When I hit:
const token = await admin.auth().createCustomToken('test', {
isAdmin: true,
})
the following error is thrown
Permission iam.serviceAccounts.signBlob is required to perform
this operation on service account
projects/-/serviceAccounts/[email protected].;
Please refer to
https://firebase.google.com/docs/auth/admin/create-custom-tokens
for more details on how to use and troubleshoot this feature
In the referenced documentation it says to add the Service Account Token Creator role to the service account. I have added that role (as well as tried Service Account Admin to no avail.
I can verify that my permissions seem to be correctly set, when I run
gcloud projects get-iam-policy project
I can see my service account attached to the desired role
- members:
- serviceAccount:[email protected]
role: roles/iam.serviceAccountTokenCreator
However if I look at that specific service account, it seems to show up empty which would fall in line with my error:
gcloud iam service-accounts get-iam-policy [email protected]
etag: ACAB
- Why would those two commands & cloud console show differing information?
I assume that whatever is causing my service account permissions to show up blank is the culprit, but I'm not sure where to debug further. It seems to me the only difference is one command is called with a project in it, but I initialize my firebase app with the project id, and have verified it with (firebase-admin).apps[0].options
so it seems like a dead end.
initializeApp
not the service account used by the code? I am using the same service account, and see it listed when I look at the initialized apps options.admin.initializeApp({ projectId:project, serviceAccountId: [email protected]', });
– Sprawl