新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

JWT with Python SDK giving "Could not unserialize key data."

新規投稿

コメント

10件のコメント

  • uberscout

    I'm also running into this same issue.

    0
    コメントアクション Permalink
  • Murtza

      I am not sure why you are seeing this error, but according to this thread it might be an issue with the format of the private key you are using.

    0
    コメントアクション Permalink
  • uberscout

    I was looking at the Box SDK and it looks like it's in the JWTAuth object (jwt_auth.py) specifically:

     

    ```

    with open(rsa_private_key_file_sys_path) as key_file:
    self._rsa_private_key = serialization.load_pem_private_key(
    key_file.read(),
    password=rsa_private_key_passphrase,
    backend=default_backend(),
    )

    ```

    key_file.read() is passing it a string and it expects a bytes array (https://cryptography.io/en/latest/hazmat/primitives/asymmetric/serialization/#cryptography.hazmat.primitives.serialization.load_pem_private_key)

     

    I am just manually writing my JWT Auth but I believe the key_file.read() should be wrapped with bytes.

     

    ```

    with open(rsa_private_key_file_sys_path) as key_file:
    self._rsa_private_key = serialization.load_pem_private_key(
    bytes(key_file.read()),
    password=rsa_private_key_passphrase,
    backend=default_backend(),
    )

    ```

    0
    コメントアクション Permalink
  • uberscout

    Looks like this was fixed in an update. You should be able to do this now.

    0
    コメントアクション Permalink
  • DanEhrlich

    How do I fix this in Python 2.7?

    0
    コメントアクション Permalink
  • boobalganesan

    Which version was it fixed in? I am using 3.6 and still facing the issue.

    0
    コメントアクション Permalink
  • DimitrisT

    Same here...

    Anyone have had success?

    0
    コメントアクション Permalink
  • DimitrisT

    I was not decrypting my private key -- duh!

    0
    コメントアクション Permalink
  • SS90

    I don't know if this will help now or not but, you need to ensure that rsa_private_key_passphrase is in bytes and not string.

    So instead of -

    rsa_private_key_passphrase='XXXXXXX',

    use -

    rsa_private_key_passphrase=b'XXXXXXX', (for bytes)

    0
    コメントアクション Permalink
  • z07diac

    Did you solve this problem?

    0
    コメントアクション Permalink

サインインしてコメントを残してください。