Google云端-来自其他电子邮件地址的项目ID错误 [英] Google Cloud - Wrong project id being used from different email address

查看:77
本文介绍了Google云端-来自其他电子邮件地址的项目ID错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管运行gcloud auth application-default logingcloud config set core/project CORRECT_PROJECT_ID,该项目仍默认使用错误的项目ID:

Despite running gcloud auth application-default login and gcloud config set core/project CORRECT_PROJECT_ID the project keeps defaulting to an incorrect project id:

gcloud config list
[core]
account = CORRECT_EMAIL
disable_usage_reporting = True
project = CORRECT_PROJECT_ID

Your active configuration is: [default]

如果我在终端中运行,我可以成功运行本教程中的示例代码(如下) 导出GOOGLE_APPLICATION_CREDENTIALS ="[PATH]"

I can successfully run the sample code from the tutorial (below) if I run in the terminal export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

但是,我不想每次都这样做,所以我运行了命令:

However, I didn't want to have to do this every time, so I ran the command:

gcloud auth application-default login

这将打开一个浏览器,其中包含我的gmail帐户列表,即使我选择了正确的帐户,成功窗口也会转到另一个gmail帐户.因此,我在隐身窗口中尝试了此方法,然后它起作用了.

This opened a browser with a list of my gmail accounts, and even though I selected the correct account, the success window went to a different gmail account. So then I tried it in an incognito window, and it worked.

但是,运行npm start会导致以下错误:

However, running npm start resulted in the following error:

ERROR: { Error: 7 PERMISSION_DENIED: Cloud Natural Language API has not been used in project WRONG_PROJECT_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=WRONG_PROJECT_ID then retry.

然后我跑gcloud config set core/project CORRECT_PROJECT_ID并收到消息Updated property [core/project].

当我运行npm start时,我会收到相同的消息:

When I run npm start I get the same message:

ERROR: { Error: 7 PERMISSION_DENIED: Cloud Natural Language API has not been used in project WRONG_PROJECT_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=WRONG_PROJECT_ID then retry.

我尝试了gcloud auth login并收到了以下消息(在隐身窗口中通过身份验证之后):

I tried gcloud auth login and got the following message (after I authenticated in an incognito window):

WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

You are now logged in as [CORRECT EMAIL ADDRESS].
Your current project is [CORRECT_PROJECT_ID].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID

推荐答案

我有一些建议可以纠正此行为.

I have a few suggestions that may correct this behaviour.

1)清除您的Web浏览器缓存&饼干.然后运行"gcloud auth应用程序-默认登录名"

1) Clear your web browser cache & cookies. Then run "gcloud auth application-default login"

2)尝试重新安装gcloud工具箱.

2) Try re-installing the gcloud toolkit.

3)首先尝试取消设置配置中的项目,然后将项目设置为正确的项目.即

3) Try unsetting the project in your config first, then set the project to the correct project. i.e.

gcloud config unset project WRONG_PROJECT_ID
gcloud config set project CORRECT_PROJECT_ID

4)检查"CLOUDSDK_CORE_PROJECT" 环境变量.如果尚未将其设置为正确的项目.

4) Check the "CLOUDSDK_CORE_PROJECT" environment variable. Set it to the correct project if it is not already.

5)尝试重新运行"gcloud init"

6)您可以在

Linux:〜/.config/gcloud/application_default_credentials.json

Linux: ~/.config/gcloud/application_default_credentials.json

Windows:C:\ Users \%username%\ AppData \ Roaming \ gcloud \ credentials

Windows: C:\Users\%username%\AppData\Roaming\gcloud\credentials

您可以删除文件&使用您在问题中提到的命令(例如"gcloud auth default-credentials login")重新生成它

You can delete the file, & regenerate it using commands you had mentioned in your question such as "gcloud auth default-credentials login"

我们需要找到npm start从何处获取其凭据.一旦弄清楚了,就可以弄清楚如何更改它,&了解为什么要在那里等.

We need to find where npm start is getting its credentials from. Once we figure that out, we can figure out how to change it, & understand why it’s looking there etc.

您是否能够找到配置文件以查看其在何处寻找凭证? 是npm启动整个命令吗?我对Node JS不太熟悉.我不确定为什么要尝试使用自然语言API. 您还提到了一个教程,但我想您可能忘记了将其包含在问题中.您指的是哪个教程?

Are you able to find the config file to see where it is looking for credentials? Is npm start the entire command? I’m not too familiar with Node JS. I’m not sure why it is trying to use Natural Language API. You also mentioned a tutorial but I think you may have forgotten to include it in your question. Which tutorial are you referring to?

这篇关于Google云端-来自其他电子邮件地址的项目ID错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆