簡體   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