HTTP Error: 403, Permission denied to enable service [cloudfunctions.googleapis.com] - firebase

I have firebase admin permission and cloud functions admin access but even then when I try to run firebase init functions command it gives me following error.
Error: HTTP Error: 403, Permission denied to enable service [runtimeconfig.googleapis.com] Help Token *******
I found similar question here. but not sure will it work or not as I am not owner.
I am not sure what is causing this error or permission or role is missing. Please help me on this.
#AskFirebase

I found out the issue. I had Firebase Admin and Cloud Function Admin role. But to enable any of the api user should have Owner or Editor role.
Please refer to this link here
UPDATE
Due to security reason owner of the project was not able to give me editor role. If you are in such situation than granting user following two role will allow them to perform command such as firebase init functions
Cloud Function Admin
Service Account User

I had this issue when deploying Cloud Functions from Cloud Build with the firebase community builder.
It turned out that I missed the "Required IAM permissions" part when following the instructions. Basically, add Cloud Build Service Account, Firebase Admin and API Keys Admin roles, to the the email ending with #cloudbuild.gserviceaccount.com.
Reference: https://cloud.google.com/build/docs/deploying-builds/deploy-firebase

Related

Access Denied - After Typing Firebase Init?

I just registered my own domain on GCP and instead, created a new GCP. I wanted to migrate my old GCP to new one. So, I signed in using firebase login:ci. The new window opened up to choose my account and I used my new assigned account for registered domain on new GCP. Then I run firebase init inside. I got this error after selecting firebase project I created using a new GCP.
Error: HTTP Error: 403, Permission denied to get service [firestore.googleapis.com]
Help Token: AWzfkCMe3kI1xtpLJkoCpzQg-sn3fQt7oX8VPut5qpv5cBZcYLNuMwx9Ml1UofnrC9fStBNhbTPnPBJlx-jiM4Br3U-pBp91mmYWnqnrOxClIEQY
The firebase login:ci command is used for authentication in CI pipelines. To authenticate yourself to for Firebase CLI, use firebase login.
Checkout the documentation for more information.
As mentioned by #Dharmaraj you can use firebase login to Log into Firebase using your Google account. This command connects your local machine to Firebase and grants you access to your Firebase projects.

Firebase CLI using a wrong service account despite being logged in to another

I have recently started learning about building a serverless backend using Firebase for the cloud functions. I have been able to set up a Firebase project with some functions, which I would like to deploy. However, since I have previously logged in with another service account, it does not allow me to deploy despite the fact that I logout first and then login with the proper account.
I logout with firebase logout, which states Logged out from ....#gmail.com. Then I login with the proper account with firebase login, which opens my browser so that I can login with my account.
When I try to deploy with firebase deploy it throws an error
Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account previousAccount#appspot.gserviceaccount.com.
To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL:
https://console.cloud.google.com/iam-admin/iam?project=previousAccount
I have also tried setting the proper account as the default one for the project directory, but that did not address the issue.
How can I erase the other service account and start using the proper one?

Firebase Google sign error: This domain is not authorized to run this operation

I just deploy my react app to firebase , after deployment I am having trouble getting the Firebase Google sign-in to work and got the error :"This domain (*********.web.app) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab."
see the error in below pic:
See This
also I've whitelist the domain and add it to authentication tab
See This
,but don't know why I still got the error. Can Anyone help me with this issue?
This problem is likely due to the sign-in methods that are enabled. In the firebase console, you need to enable the Google sign-in method

I can't deploy Firebase functions because I don't have "Service Account User" Role

I'm trying to deploy Firebase Functions like so:
firebase deploy --only functions
However, I'm getting the following error:
Error: Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account xyz#appspot.gserviceaccount.com.
To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL:
https://console.cloud.google.com/iam-admin/iam?xyz
I've already given myself Service Account User permission by going to
Identity -> Service Accounts -> xyz#appspot.gserviceaccount.com -> Permissions -> + Grant Access
I've added my email and service account linked in GOOGLE_APPLICATION_CREDENTIALS. I'm still getting the same error.
Any ideas?
Can you verify that you are logged with the correct account and that you are linked to the project?
You can double check by creating a new project and then in cli
$ firebase logout
$ firebase login
$ firebase init

Firebase login with GCP service account

I am trying to login to the Firebase Tools CLI with a GCP service account. I have the path to the service account credentials saved as GOOGLE_APPLICATION_CREDENTIALS. I have logged out of firebase with firebase logout and have tried to sign in with the service account with firebase login --no-localhost and firebase login --no-localhost --token $GOOGLE_APPLICATION_CREDENTIALS. However in bother cases a web browser opens asking me to log in with my user account. How can I log in to firebase with a service account?
Taken from Michael Bleighs comment:
"The Firebase CLI does support GOOGLE_APPLICATION_CREDENTIALS, but you don't need to "log in" with them. If the environment variable is pointing to a valid service account you should be able to just use CLI commands as if you are logged in. You do need to be logged out for GAC to work correctly. Run the command with --debug if you're getting errors while trying to do so."
I can confirm I have this working. Note you might need to run firebase use <project-id> for it to work correctly.
You can't sign in to your Firebase project with a service account. You will need to use the proper user account of a collaborator on the project to sign in with Firebase tools.
Even when using the CI integration, the documentation says to:
Start the signin process by running the following command:
firebase login:ci
Visit the URL provided, then sign in using a Google account.

Resources