简体   繁体   English

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

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

Im having trouble getting identity-toolkit fully working with Python App Engine Sandbox. 我在使身份工具包与Python App Engine沙箱完全兼容时遇到麻烦。 The sample provided is for a non GAE Sandbox project. 提供示例适用于非GAE沙盒项目。

In the sample project it reads gitkit-server-config.json from file using os.path . 在示例项目中,它使用os.path从文件读取gitkit-server-config.json But this is not supported in GAE Sandbox. 但这在GAE Sandbox中不受支持。 To get around this I am creating a GitkitClient directly using the constructor: 为了解决这个问题,我直接使用构造函数创建一个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")

Is this the correct way to create the GitkitClient? 这是创建GitkitClient的正确方法吗?

The issue now is when I try to do a password reset when running locally using dev_appserver.py I get the following stack trace: 现在的问题是,当我尝试使用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.

Im assuming this is a problem with the .p12 file? 我假设这是.p12文件的问题? I double checked service_account_key="/path/to/my-p12file.p12" and the file exists. service_account_key="/path/to/my-p12file.p12"检查了service_account_key="/path/to/my-p12file.p12" ,该文件已存在。 What am I missing here? 我在这里想念什么?

FYI to others working on this in the future - 仅供参考,以供日后从事此工作的其他人-

I could not get this working in python. 我无法在python中工作。 The documentation doesn't make it clear how to get this working in app engine. 该文档没有明确说明如何在App Engine中正常工作。 In addition, dependency issues with PyCrypto made this a gcc and dependency nightmare. 此外,PyCrypto的依赖性问题使这成为了gcc和依赖性噩梦。

I was however able to get this working in Go and there is a semi-working example online that will work with some modifications highlighted in the issues and pull request pages. 但是,我可以在Go中使用它,并且有一个在线的半工作示例 ,该示例可以对问题请求请求页面中突出显示的部分进行修改。 Good luck. 祝好运。

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

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