11

I was trying to deploy my first firebase cloud function using firebase cli but I encountered an error instead :

C:\Users\Anurag Tripathi\Desktop\firebasecloudfunction> firebase deploy --only functions

Error: Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account  project_number@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=project_number

I tried to solve the problem by following the instruction but didn't get any success . Please help.

Edit : I have abandoned the project :( , so I really can't test the answers. Thanks all for the answers and comments. I will accept the most upvoted answer.

Anurag Tripathi
  • 707
  • 1
  • 6
  • 17

7 Answers7

8

As specified in the docs, apart from the Service Account User role, you should assign the Cloud Functions Admin role to the Service Account that you are using to deploy the functions

Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
Jose V
  • 1,356
  • 1
  • 4
  • 12
  • 2
    I have already given project-id@appshot.gserviceaccount.com Service Account User role and Cloud Function admin role but I am still getting the same error . Do you know which service account is used for deploying functions – Anurag Tripathi May 14 '20 at 07:51
  • You should assign those permissions to whichever account you logged in with when setting up the Firebase CLI in you machine – Jose V May 14 '20 at 08:16
  • No, it didn't work . The error message says assign service account user role to project-number@appshot.gserviceaccount.com . But I can't find this service account in the list of service accounts on GCP. I have project-id@appshot.gserviceaccount.com but not project-number . What do you suggest I do ? – Anurag Tripathi May 14 '20 at 09:17
  • 1
    I am still getting the same error has anyone found a solution – lemmy njaria May 14 '20 at 12:36
  • @anurag7, you should be able to see the service account in the [IAM page](https://console.cloud.google.com/iam-admin/iam). Make sure you have the correct project selected – Jose V May 18 '20 at 13:26
  • I have this exactly problem since today (last week I was able to deploy) no clue about how to solve. the account have all the permissions, bassically I testeed by adding Service Accout and Admin roles, Cloud function and Admin Cloud functions roles and nothings works :/ – rkmax Jun 22 '20 at 21:12
  • I think for most people searching this will be the correct answer but the others are good to know as well. – acheo Feb 27 '21 at 15:45
7

This is what worked for me. First run firebase login:list to find out if the account logged into firebase cli is the same account authorized in your Google Cloud Console. If not, run firebase logout <email> then firebase login, then deploy again.

Solomon Metta
  • 85
  • 1
  • 6
5

It turned out I had the wrong project name in the .firebaserc file. After changing the name to the correct google cloud project name it worked.

D. Sackey
  • 59
  • 1
  • 4
5
firebase projects:list

If the current Firebase account doesn't have your project, you have to logout first.

firebase logout  
firebase login
firebase projects:list

enter image description here

firebase use <project ID>

So for example,

firebase use stripesample1


firebase projects:list

enter image description here

firebase deploy --only functions
Gene
  • 10,819
  • 1
  • 66
  • 58
2

I was having same issue, I just did firebase logout and firebase login and issue resolved

SKG
  • 774
  • 6
  • 7
  • I think it is working , I didn't encounter the permission error , though there are some error in my code which I will fix later . Wow , after so much head scratching and the solution is quiet simple . Thanks ! – Anurag Tripathi Jul 05 '20 at 06:48
  • 1
    OK , I accepted the answer because that firebase logout and login worked for me at that time but now I am facing the same issue again . Any help would be appreciated . – Anurag Tripathi Jul 14 '20 at 05:49
0

I had this issue with a co-worker who inherited the Firebase Admin role from the Organization the project belongs to.

I confirmed he had inherited the role but not all the same permissions as when you assign the role manually from Firebase Console -> Users and Permissions.

So, I could have followed the instructions in the link shown in the error log. But I thought it was safer to just re-assign the Firebase Admin role from firebase console. That solved the issue.

maganap
  • 2,414
  • 21
  • 24
0

I met with this same error.what i have went through is, when i list my project using firebase projects:list i have found my project listed.But when i try to use the project using use firebase use <project ID>, i got the error permission error. Its a simple mistake i made. try firebase login, confirm that u have signedin to the project you are working in. If not, try firebase logout then login with proper account.Thats it summarising:

firebase login
firebase logout
firebase login
ashique
  • 935
  • 2
  • 8
  • 26