0
votes

I am having an issue with gcloud and firebase interfering. I have a project that requires gcloud auth — however I started a new firebase project separate from my gcloud project. My firebase project should be using my firebase authentication — instead I am getting the following error:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
>      at GoogleAuth.getApplicationDefaultAsync (/Users/project/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)
>      at processTicksAndRejections (internal/process/task_queues.js:97:5)
>      at async GoogleAuth.getClient (/Users/project/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)
>      at async GrpcClient._getCredentials (/Users/project/functions/node_modules/google-gax/build/src/grpc.js:92:24)
>      at async GrpcClient.createStub (/Users/project/functions/node_modules/google-gax/build/src/grpc.js:213:23)

If I do log into my account via gcloud auth login then replacing GOOGLE_APPLICATION_CREDENTIALS in .bash_project — I do not get the error above. I do get the following warning:

Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to /Users/.config/gcloud/legacy_credentials/xxx/xxx.json. Non-emulated services will access production using these credentials. Be careful!

From my understanding firebase does not need you to setup gcloud and should use the credentials giving at firebase login, I’m not sure how to keep these two separate. I would prefer not to have to change GOOGLE_APPLICATION_CREDENTIALS each time I need to switch projects and not to get the warning I’ve been receiving.

1

1 Answers

0
votes

I don't think you can somehow fix this. Still, I've been able to think of four different workarounds for your scenario but I'm not sure they will fit your needs. They are sorted by how convenient they are:

  • Give any of the two accounts privileges on the other project and use only that account. This would work since you'd only need a single account and you would have to change the environment variable.
  • In one of the projects retrieve the credentials from another environment variable instead of GOOGLE_APPLICATION_CREDENTIALS. I'm not sure if this fits you because I don't know where are you using it, but it may suit you depending on the scenario.
  • Create a simple script that just changes the value of the environment variable and run it when changing projects. This is not ideal and what you are seeking to avoid, but would be easier than manually changing the value.
  • Use two different users on your computer with each one having a different credential stored in the environment variable. This isn't complicated, but you'd have to change users when using one project or another, which implies the same negative aspects of the previous proposal.