HTTP Error: 401 while setting up firebase cloud functions for android project

FirebaseGoogle Cloud-FunctionsFirebase Cli

Firebase Problem Overview


I`m trying to set up firebase functions, but I get an error after running firebase init.

Error: HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

enter image description here

Firebase Solutions


Solution 1 - Firebase

I solved the problem! you need to logout firebase logout then log-in firebase login again or just refresh the token with firebase login --reauth

it seems that the expiry time of Firebase auth token is limited to max 1Hr

Solution 2 - Firebase

Use firebase login --reauth, that happened to me because an old FIREBASE_TOKEN was present while trying to exec firebase init

Solution 3 - Firebase

I solved it by manually deleting the FIREBASE_TOKEN from my environment variables, THEN issued a firebase login --reauth.

Note: I tried to re-authenticate without deleting the Firebase token first, but didn't work for me.

Solution 4 - Firebase

Had the same issue but with firebase hosting. For some reason only using sudo firebase I managed to make it work

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionM.AliView Question on Stackoverflow
Solution 1 - FirebaseM.AliView Answer on Stackoverflow
Solution 2 - FirebasepixshattererView Answer on Stackoverflow
Solution 3 - FirebaseTheFabbiusView Answer on Stackoverflow
Solution 4 - FirebaseMikhail MazurovskiyView Answer on Stackoverflow