【发布时间】:2018-09-13 15:14:50
【问题描述】:
我想使用 Google Talent Solution (GTS)。
set-up docs 解释了如何使用服务帐户设置标准环境 App Engine 项目。我在我的 App Engine 项目中启用了 GTS,启用了数据记录,并在启用 GTS 时创建的App Engine default service account 中添加了一个Service Account Token Creator - [app-id]@appspot.gserviceaccount.com。
我为 Python AppEngine 项目使用了 read the docs,但它使用了 deprecated API oauth2client,而我正在尝试使用 google_auth(我已经安装并出售了 google_api 和 google_auth。
在我的供应商appengine_config.py:
from google.appengine.ext import vendor
import os
google_api_path = "%s%s" % (os.path.dirname(os.path.realpath(__file__)), '/applications/[app-id]/modules/google_api')
vendor.add(google_api_path)
google_auth = "%s%s" % (os.path.dirname(os.path.realpath(__file__)), '/applications/[app-id]/modules/google')
vendor.add(google_auth)
我将 google_auth 安装到名为 google 的目录中。在一个目录路径/applications/[app-id]/modules/ 中,它可以与 Python 框架 Web2py 很好地配合使用。
我的代码:
from google.auth import app_engine
credentials = app_engine.Credentials()
print(credentials.token)
唉,credentials.token 是 None
在所有这些设置、配置和代码中,我错过了什么?
【问题讨论】:
-
我错过了设置
a security requirement object and a security definitions object in your OpenAPI configuration file to support authentication of a calling service。试试这个。 -
添加了 OpenAPI 配置文件后,对 app_engine.Credentials() 的调用仍会返回令牌成员设置为 None 的对象
标签: google-app-engine google-api