AttributeError:“模块”对象没有属性“GoogleCredentials”
我有一个在 localhost 上运行的 appengine 应用程序。我有一些我运行的测试,我想使用 remote_api 来检查 db 值。当我尝试通过访问来访问 remote_api 时:
'http://127.0.0.1:8080/_ah/remote_api'
我得到一个:
"This request did not contain a necessary header"
但它在浏览器中工作。
当我现在尝试通过调用从我的测试中调用 remote_api
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:35887','/_ah/remote_api')
我得到错误:
Error
Traceback (most recent call last):
File "/home/dan/src/gtup/test/test_users.py", line 38, in test_crud
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:35887','/_ah/remote_api')
File "/home/dan/Programs/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 747, in ConfigureRemoteApiForOAuth
credentials = client.GoogleCredentials.get_application_default()
AttributeError: 'module' object has no attribute 'GoogleCredentials'
我确实尝试重新安装整个谷歌云,但这没有用。
当我打开client.py
google-cloud-sdk/platform/google_appengine/lib/google-api-python-client/oauth2client/client.py
我可以看到,remote_api_stub.py 使用它,其中没有 GoogleCredentials 类。
GoogleCredentials 类存在,但位于其他 client.py 文件中:
google-cloud-sdk/platform/google_appengine/lib/oauth2client/oauth2client/client.py
google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/client.py
google-cloud-sdk/platform/bq/third_party/oauth2client/client.py
google-cloud-sdk/lib/third_party/oauth2client/client.py
我的 app.yaml 看起来像这样:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: webapp2
version: latest
builtins:
- remote_api: on
handlers:
- url: /.*
script: main.app
这只是 appengine 内部的错误导入/错误吗?还是我在单元测试中使用 remote_api 做错了什么?