1
我使用的API示例为here。无法在Cloud Natural Language中设置项目API
运行gcloud config list
显示我的默认项目为project = multichoice-insights
重要的代码摘录显示,我得到了默认凭据:
credentials = GoogleCredentials.get_application_default().create_scoped(
['https://www.googleapis.com/auth/cloud-platform'],
)
然而,当我尝试使用API,我得到的错误消息:
googleapiclient.errors.HttpError: <HttpError 403 when requesting
https://language.googleapis.com/v1beta1/documents:analyzeSentiment?
alt=json returned "Google Cloud Natural Language API has not been used
in project google.com:cloudsdktool before or it is disabled. Enable it
by visiting
https://console.developers.google.com/apis/api/language.googleapis.com/over
view?project=google.com:cloudsdktool then retry. If you enabled this
API recently, wait a few minutes for the action to propagate to our
systems and retry.">
我认为,这显示使用的项目:project=google.com:cloudsdktool
我该如何将其更改为project-name
?
我已经在控制台中启用了这个api。
设置GOOGLE_APPLICATION_CREDENTIALS env var在我的情况下没有解决问题......它在生产(AppEngine)中工作,但不能在开发中运行......任何其他人都有相同的问题? – Neurus
尝试使用'未设置GOOGLE_APPLICATION_CREDENTIALS'取消设置您的env var,然后尝试使用'gcloud auth application-default login' 有趣的是看看它是否有效。 –