Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python GAE:远程api和应用程序默认凭据_Python_Google App Engine_Google Cloud Datastore - Fatal编程技术网

Python GAE:远程api和应用程序默认凭据

Python GAE:远程api和应用程序默认凭据,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,从今天起,我一直在使用(python)访问GAE上的数据存储 我通常使用remote\u api\u shell.py-s 今天我尝试了,但失败了,错误是: oauth2client.client.ApplicationDefaultCredentialsError: 应用程序默认凭据不可用。它们是可用的 如果在谷歌计算引擎中运行。否则,环境 变量GOOGLE_应用程序_凭据必须定义为指向 定义凭据的文件。看见 了解更多信息 我不明白为什么它问我这个问题 wole输出如下 stefano@~/g

从今天起,我一直在使用(python)访问GAE上的数据存储

我通常使用
remote\u api\u shell.py-s

今天我尝试了,但失败了,错误是:

oauth2client.client.ApplicationDefaultCredentialsError: 应用程序默认凭据不可用。它们是可用的 如果在谷歌计算引擎中运行。否则,环境 变量GOOGLE_应用程序_凭据必须定义为指向 定义凭据的文件。看见 了解更多信息

我不明白为什么它问我这个问题

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.
stefano@~/gc$remote\u api\u shell.py-s。。。。
回溯(最近一次呼叫最后一次):
文件“/usr/local/bin/remote_api_shell.py”,第133行,在
运行\u文件(\uuuu文件,globals())
文件“/usr/local/bin/remote\u api\u shell.py”,第129行,在run\u文件中
execfile(_PATHS.script_文件(script_名称),全局文件)
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/google/appengine/tools/remote\u api\u shell.py”,中第157行
主(系统argv)
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/google/appengine/tools/remote\u api\u shell.py”,主文件第153行
appengine_rpc.HttpRpcServer)
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/google/appengine/tools/remote\u api\u shell.py”,第74行,位于remote\u api\u shell中
安全的
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/google/appengine/ext/remote\u api/remote\u api\u stub.py”,第734行,在ConfigureRemoteApiForOAuth中
credentials=client.GoogleCredentials.get\u application\u default()
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/lib/oauth2client/oauth2client/client.py”,第1204行,在get\u application\u default中
返回Google凭据。\u获取\u隐式\u凭据()
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/lib/oauth2client/oauth2client/client.py”,第1194行,在获取隐式凭证中
引发ApplicationDefaultCredentialsError(ADC\u帮助\u消息)
oauth2client.client.ApplicationDefaultCredentialsError:应用程序默认凭据不可用。如果在谷歌计算引擎中运行,它们是可用的。否则,必须定义指向定义凭据的文件的环境变量GOOGLE\u APPLICATION\u CREDENTIALS。看见https://developers.google.com/accounts/docs/application-default-credentials 了解更多信息。

解决方案是在shell中运行
gcloud auth login
,然后再次授予权限

  • 转到API管理器>>凭据下的开发人员控制台(当前位于
    https://console.developers.google.com/apis/credentials?project=
  • 单击服务帐户,然后单击标记为“生成新JSON密钥”的按钮
  • 将下载一个文件,并将其保存在安全的位置
  • 将环境变量GOOGLE_APPLICATION_CREDENTIALS设置为指向运行远程_api_shell.py之前保存的文件

  • 我一直在使用google app engine,但从未安装过gcloud。有没有其他方法可以达到同样的效果?