'Newly Created Firebase Functions Throwing UNAUTHENTICATED Error

I have a Firebase project with over 10 cloud functions. Today I added 3 more, but all three of the new ones are throwing an error UNAUTHENTICATED without actually trying to hit the function. (There's no record of a function call in the logs). I haven't made any changes to my environment or Firebase project since adding the previous functions.

I have tried redeploying all of the functions in my project, the three newest ones continue to fail while the previous ones work fine. I have also verified that I am using Node 8, since there are some similar issues reported stemming from using Node 10. I am not sure what else to try since the issue only applies to the new functions.

The new functions all have a similar signature:

exports.createGroup = functions.https.onCall((data, context) => {
  //Firestore access
});

They are being called like this:

const create = functions().httpsCallable('createGroup');
return create({ group: oGroup }).then(result => {
      //Do something
}).catch(err => {
      console.log(err.message); //UNAUTHENTICATED
});

Node Version: 8.16.2

Firebase Tools Version: 7.6.1



Solution 1:[1]

It must be solved at your GCP Console (not Firebase). Just follow these steps:

  1. Go to your GCP Console and login
  2. On the top menu, select the corresponding Firebase project
  3. On the left menu go to Cloud Functions Click the checkbox of your function (not the name of the function)
  4. Once selected, on the right menu select "Add member"
  5. On "New member" type allUsers
  6. On the Select function bar, select Cloud Functions -> Cloud functions invoker
  7. Click on "Save" and then "Allow public access" on the pop-up warning And you're good to go!

Solution 2:[2]

2022 UPDATE:


 1. Go to the Google Cloud Console:
          
 2. Click the checkbox next to the function to which you want to grant  
    access.

 3. Click Permissions at the top of the screen. The Permissions panel   
    opens.

 4. Click Add principal.

 5. In the New principals field, type allUsers

 6. Select the role Cloud Functions > Cloud Functions Invoker from the  
    Select a role drop-down menu.    

 7. Click Save.

Solution 3:[3]

I ran into this error when deploying several functions and there was an issue during the upload where it seems the deployment got corrupted .. perhaps network related, not sure

After deleting the offending cloud functions in the Firebase console, and then doing a fresh successful deploy for them, the "FirebaseFunctionsException UNAUTHENTICATED" error went away

First I tried to just redeploy the functions, but that was not enough, the error continued this way

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar Said López Tronco
Solution 2 Lukas Niessen
Solution 3