【问题标题】:How to get p12 file working on python app engine如何让 p12 文件在 python 应用程序引擎上工作
【发布时间】:2016-03-19 21:35:28
【问题描述】:

我无法让身份工具包与 Python App Engine Sandbox 完全配合使用。 sample provided 用于非 GAE 沙盒项目。

在示例项目中,它使用os.path 从文件中读取gitkit-server-config.json。但这在 GAE 沙盒中不受支持。为了解决这个问题,我直接使用构造函数创建了一个 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" 并且文件存在。我在这里错过了什么?

【问题讨论】:

    标签: python google-app-engine google-identity-toolkit


    【解决方案1】:

    仅供未来从事此工作的其他人参考-

    我无法让它在 python 中工作。该文档没有明确说明如何使其在应用程序引擎中工作。此外,PyCrypto 的依赖问题使这成为 gcc 和依赖的噩梦。

    然而,我能够在 Go 中实现这一点,并且有一个在线 semi-working example 可以使用在 issuespull request 页面中突出显示的一些修改。祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-13
      • 1970-01-01
      • 2017-03-16
      • 2017-03-30
      • 2021-07-05
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      相关资源
      最近更新 更多