GAE:remote_api和应用程序默认凭证 [英] GAE: remote_api and Application Default Credentials
问题描述
由于今天我一直使用 remote_api (python)访问数据存储GAE。
我通常做 remote_api_shell.py -s< mydomain>
。
今天我试过了,但是失败了,错误是:
$ b
oauth2client.client.ApplicationDefaultCredentialsError:
应用程序默认凭证不可用。如果在Google Compute Engine中运行,它们可用
。否则,环境
变量GOOGLE_APPLICATION_CREDENTIALS必须定义为指向定义凭据的
文件。请参阅
https://developers.google.com/accounts/docs/
我不明白为什么它会问我这个问题。
输出是这样的
stefano @〜/ gc $ remote_api_shell .py -s ....
Traceback(最近一次调用最后一次):
在< module>文件中的/usr/local/bin/remote_api_shell.py,第133行。
run_file(__ file__,globals())
文件/usr/local/bin/remote_api_shell.py,第129行,在run_file中
execfile(_PATHS.script_file(script_name),globals_)
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py,第157行,位于< module>
main(sys.argv)
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py,第153行,主
appengine_rpc.HttpRpcServer)
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell。 py,第74行,位于remote_api_shell
secure = secure)
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext /Remote_api/remote_api_stub.py,第734行,位于ConfigureRemoteApiForOAuth
credentials = client.GoogleCredentials.get_application_default()
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents /Resources/google_appengine/lib/oauth2client/oauth2client/client.py,行1204,在get_application_default
中返回GoogleCredentials._get_implicit_credentials()
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client .py,第1194行,在_get_implicit_credentials
中引发ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError:应用程序默认凭据不可用。如果在Google Compute Engine中运行,则它们可用。否则,必须定义环境变量GOOGLE_APPLICATION_CREDENTIALS,指向定义凭据的文件。有关更多信息,请参阅https://developers.google.com/accounts/docs/application-default-credentials。
解决方案是运行 gcloud auth login
,然后再次授予
Since today i've been using remote_api (python) to access the datastore on GAE.
I usually do remote_api_shell.py -s <mydomain>
.
Today I tried and it fails, the error is:
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.
I cannot understand why it asks me that.
the wole output is this
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.
The solution is to run gcloud auth login
in the shell and give the grant again
这篇关于GAE:remote_api和应用程序默认凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!