【发布时间】:2022-03-11 05:41:27
【问题描述】:
我正在使用 Python 客户端库在 GCP 中运行一些脚本来执行一些临时作业。
这些是临时的,因此我认为它们应该在我的最终用户凭据而不是服务帐户上运行。
我不断看到这个警告,这让我很难调试我的脚本标准输出:
UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. We recommend you rerun `gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see https://cloud.google.com/docs/authentication/
我执行了建议的gcloud auth application-default login,但仍然重复出现相同的警告消息。
如何禁用此警告?
【问题讨论】:
-
我不确定我是否理解您的问题。如果您想禁用所有警告,您可以随时利用--verbosity flag 并运行带有设置为
error的标志的每个命令(例如 gcloud auth init --verbosity="error")。运行gcloud config set core/verbosity error将更新您的 default configuration 上的值,并且您运行的所有 gcloud 命令将默认使用该详细级别。 -
如果您认为上面的评论没有用,请发布您的特定脚本的最低限度、可重现的示例,但不要分享任何合理的数据以及对您的脚本功能的简要说明。我建议您通过 this documentation 在使用 gcloud 命令编写脚本时提供一些有用的建议。
-
我想我应该提到,我正在使用 Python 客户端库
-
编辑您的帖子以包含您的脚本代码的最小可重现示例可能会有用! Python client libraries 处理基于环境变量的所有低级别身份验证,或指向具有服务帐户特定凭据的文件。你在用google-auth¶
-
@DanielOcando 我的评论怎么了?嗯