无法通过appcfg.py下载数据。 “应用程序默认凭据不可用”错误

时间:2015-10-23 20:26:42

标签: google-app-engine google-compute-engine google-oauth2

这已经有效多年了。今天不行。

正在运行appcfg.py download_data --flags...,无法获得正确授权。

gcloud auth login

然后回来了:

Saved Application Default Credentials.

You are now logged in as [correct@gmail.com].
Your current project is [correct].

但是当我运行appcfg.py download_data ...时,我收到此错误:

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.

我更新了Google Cloud SDK,现在又出现了不同的错误:

client.py:539 Attempting refresh to obtain initial access_token 
client.py:797 Refreshing access_token 

Error 302: --- begin server output ---

--- end server output ---

我还在终端设置了凭据:

set GOOGLE_APPLICATION_CREDENTIALS "https://www.myurl/credentials.json"
set CLOUDSDK_PYTHON_SITEPACKAGES 1
gcloud config set project "correct_project_name"

我也尝试在appcfg命令中设置env_variable标志:

--env_variable=GOOGLE_APPLICATION_CREDENTIALS:"https://www.myurl/credentials.json"

似乎是一个GAE错误。从app.yaml中的remote_api处理程序中删除登录名:admin将其修复为生产中,但不是本地开发服务器。 302告诉我应用程序正在尝试重定向,可能是谷歌登录页面。从来没有看到提示要求电子邮件和密码。

handlers: 
- url: /remote_api
  script: google.appengine.ext.remote_api.handler.application
  #login: admin  <-- removing admin fixes it in production
  secure: always

在开发服务器上,删除管理员登录会产生以下结果:

client.py:797 Refreshing access_token 
Error 401: --- begin server output ---
You must be logged in as an administrator to access this.
--- end server output ---

Google改变了--oauth2工作流程中的内容吗?我似乎已获得授权,但下载程序在auth步骤崩溃。

感谢。

1 个答案:

答案 0 :(得分:1)

似乎是GoogleAppEngineLauncher-1.9.27中的一个错误,它不允许登录提示。当恢复到1.9.26时,它可以工作。有趣的是,我的gcloud组件仍然具有1.9.27版本:

>$ gcloud version

Google Cloud SDK 0.9.83

alpha 2015.10.08
app 2015.10.16
app-engine-python 1.9.27
beta 2015.10.08
core 2015.10.16
core-nix 2015.09.03
gcloud 2015.10.16

临时解决方案:转到https://console.developers.google.com/storage/browser/appengine-sdks/featured/获取版本1.9.26

提交的错误报告:https://code.google.com/p/google-cloud-sdk/issues/detail?id=340