【问题标题】:GAE: remote_api and Application Default CredentialsGAE:remote_api 和应用程序默认凭据
【发布时间】:2015-09-14 14:27:41
【问题描述】:

从今天开始,我一直在使用remote_api (python) 来访问 GAE 上的数据存储区。

我通常是remote_api_shell.py -s <mydomain>

今天试了,失败了,错误是:

oauth2client.client.ApplicationDefaultCredentialsError: 应用程序默认凭据不可用。它们可用 如果在 Google Compute Engine 中运行。否则,环境 变量 GOOGLE_APPLICATION_CREDENTIALS 必须定义为指向 定义凭据的文件。看 https://developers.google.com/accounts/docs/application-default-credentials 了解更多信息。

我不明白它为什么会这样问我。

wole 输出是这样的

stefano@~/gc$ remote_api_shell.py -s ....
Traceback (most recent call last):
  File "/usr/local/bin/remote_api_shell.py", line 133, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/remote_api_shell.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 157, in <module>
    main(sys.argv)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 153, in main
    appengine_rpc.HttpRpcServer)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 74, in remote_api_shell
    secure=secure)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 734, in ConfigureRemoteApiForOAuth
    credentials = client.GoogleCredentials.get_application_default()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 1204, in get_application_default
    return GoogleCredentials._get_implicit_credentials()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 1194, in _get_implicit_credentials
    raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

【问题讨论】:

    标签: python google-app-engine google-cloud-datastore


    【解决方案1】:

    解决方案是在 shell 中运行gcloud auth login 并再次授予授权

    【讨论】:

    • 我一直在使用谷歌应用引擎,但从未安装过 gcloud。有没有其他方法可以做到这一点?
    【解决方案2】:
    1. 转到 API Manager>>Credentials 下的 Developers Console(当前位于 https://console.developers.google.com/apis/credentials?project=&lt;&lt;&lt;Your App Id&gt;&gt;&gt;)。
    2. 单击服务帐户,然后单击标有“生成新 JSON 密钥”的按钮。
    3. 将下载一个文件,将其保存在安全的地方。
    4. 将环境变量 GOOGLE_APPLICATION_CREDENTIALS 设置为指向您在运行 remote_api_shell.py 之前保存的文件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      • 2018-02-18
      • 1970-01-01
      相关资源
      最近更新 更多