繁体   English   中英

如何使P12文件在python App Engine上工作

[英]How to get p12 file working on python app engine

我在使身份工具包与Python App Engine沙箱完全兼容时遇到麻烦。 提供示例适用于非GAE沙盒项目。

在示例项目中,它使用os.path从文件读取gitkit-server-config.json 但这在GAE Sandbox中不受支持。 为了解决这个问题,我直接使用构造函数创建一个GitkitClient:

gitkit_instance = gitkitclient.GitkitClient(
    client_id="123456opg.apps.googleusercontent.com",
    service_account_email="my-project@appspot.gserviceaccount.com",
    service_account_key="/path/to/my-p12file.p12",
    widget_url="http://localhost:8080/callback",
    http=None,
    project_id="my-project")

这是创建GitkitClient的正确方法吗?

现在的问题是,当我尝试使用dev_appserver.py在本地运行时尝试重置密码时,得到以下堆栈跟踪:

 File "dashboard.py", line 89, in post
    oobResult = gitkit_instance.GetOobResult(self.request.POST,self.request.remote_addr)
  File "identitytoolkit/gitkitclient.py", line 366, in GetOobResult
    param['action'])
  File "identitytoolkit/gitkitclient.py", line 435, in _BuildOobLink
    code = self.rpc_helper.GetOobCode(param)
  File "identitytoolkit/rpchelper.py", line 104, in GetOobCode
    response = self._InvokeGitkitApi('getOobConfirmationCode', request)
  File "identitytoolkit/rpchelper.py", line 210, in _InvokeGitkitApi
    access_token = self._GetAccessToken()
  File "identitytoolkit/rpchelper.py", line 231, in _GetAccessToken
    'assertion': self._GenerateAssertion(),
  File "identitytoolkit/rpchelper.py", line 259, in _GenerateAssertion
    crypt.Signer.from_string(self.service_account_key),
  File "oauth2client/_pure_python_crypt.py", line 183, in from_string
    raise ValueError('No key could be detected.')
ValueError: No key could be detected.

我假设这是.p12文件的问题? service_account_key="/path/to/my-p12file.p12"检查了service_account_key="/path/to/my-p12file.p12" ,该文件已存在。 我在这里想念什么?

仅供参考,以供日后从事此工作的其他人-

我无法在python中工作。 该文档没有明确说明如何在App Engine中正常工作。 此外,PyCrypto的依赖性问题使这成为了gcc和依赖性噩梦。

但是,我可以在Go中使用它,并且有一个在线的半工作示例 ,该示例可以对问题请求请求页面中突出显示的部分进行修改。 祝好运。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM