Error: Failed to get Firebase project project-name. Please make sure the project exists and your account has permission to access it

Viewed 39668

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@example.com'

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?

17 Answers

For me this worked,

firebase logout

firebase login

This worked for me:

Run

firebase use --add

And re-select the project

Simply

use firebase login --reauth

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

For me, I was setting up a new machine with an existing firebase project. This is what I did:

First successfully login to firebase from your command console

firebase login

Get a list of your projects

firebase projects:list

Tell firebase which project you are using

firebase use <Project ID>

Then, I was able to deploy and use other commands for this project. Hope this helps someone.

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:

  1. `firebase logout`
    
  2. `firebase login`
    

Run

firebase use --add

And re-select the project

This works 100%

Disconnecting the company's VPN and trying it again worked for me.

Any typo inside the .firebaserc would show this error. For me I had an extra comma, removing it solved the error.

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

It's really awesome and confusing------>

just did these command ->

> firebase logout
> 
> firebase login

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.

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.

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"

1.run this firebase logout firebase login 2.if u can not login successfully , like this ? [https://i.stack.imgur.com/4MJM5.png][1]

  1. run this , export http_proxy=http://localhost:your proxy port 4.successfully!!! [https://i.stack.imgur.com/sRcvG.png][1]

It is possible you are trying to deploy without internet connection. The first thing to look for is if your internet is okay.

I got this error in Linux when I was out of disk space, freeing some space resolved it.

Related