Error: Failed to get Firebase project project-name. Please make sure the project exists and your account has permission to access it
FirebaseGoogle Cloud-FirestoreFirebase Problem Overview
I tried running firebase deploy
like I have always done but came across this Error:
> Error: Failed to get Firebase project project-name. Please make sure the project exists and your account has permission to access it.
I have run firebase login
and I get 'Already logged in as [email protected]'
The firebase-debug.log
file shows a few 401 http responses and some of them have the following text:
> 'Request had invalid authentication credentials' and also 'invalid token'
How can this be solved?
Firebase Solutions
Solution 1 - Firebase
For me this worked,
firebase logout
firebase login
Solution 2 - Firebase
This worked for me:
Run > firebase use --add
And re-select the project
Solution 3 - Firebase
Simply
use firebase login --reauth
Solution 4 - Firebase
sometimes there is a token error you can check debug.log
Error Message in debug.log : [debug] [2020-10-13T23:01:28.050Z] <<< HTTP RESPONSE BODY {"error":{"code":401,"message":"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.","status":"UNAUTHENTICATED"}}
Solution of error use
firebase login --reauth
and again firebase init
for reinitializing the project
select project and
firebase deploy
Solution 5 - Firebase
Try logging out of firebase CLI and then log back in with the account that has the project that you are trying to run.
This was the case with me. I was logged in to another firebase account.
Steps:
-
`firebase logout`
-
`firebase login`
Solution 6 - Firebase
Disconnecting the company's VPN and trying it again worked for me.
Solution 7 - Firebase
Any typo inside the .firebaserc
would show this error. For me I had an extra comma, removing it solved the error.
Solution 8 - Firebase
If none of the other answers worked for you, I had the same problem and received this solution from Firebase Support. (ty Sergei)
My system will occasionally create and Environment Variable named FIREBASE_TOKEN. The token will expire, but the variable does not. Restarts and logout/login cycles did nothing. Deleting the variable works every time though.
Remove-Item Env:\FIREBASE_TOKEN
Solution 9 - Firebase
if you use Mac or Linux, you can write this command export http_proxy=http://127.0.0.1:1087 to make sure your terminal uses the proxy, which is useful for me.
Solution 10 - Firebase
None of the above solutions worked for me but removing/editing the stored value of the default project in $HOME/.config/configstore/firebase-tools.json
did work.
Solution 11 - Firebase
It's really awesome and confusing------>
just did these command ->
> firebase logout
>
> firebase login
Solution 12 - Firebase
If you have this issue in a CI pipeline, you can regenerate a token on your local machine with
firebase login:ci
Put the generated token as an environment variable, e.g. FIREBASE_TOKEN
and run like this:
firebase deploy --token "$FIREBASE_TOKEN"
Solution 13 - Firebase
Run
firebase use --add
And re-select the project
This works 100%
Solution 14 - Firebase
I got this error in Linux when I was out of disk space, freeing some space resolved it.