docusign / docusign-esign-python-client

The Official DocuSign Python Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client. https://www.docusign.com/devcenter
MIT License
94 stars 87 forks source link

request_jwt_user_token error that can't decode a string #94

Open binyominc opened 3 years ago

binyominc commented 3 years ago

function request_jwt_user_token

following line gives an error token = jwt.encode(payload=claim, key=private_key_bytes, algorithm='RS256').decode("utf-8")

"stackTrace": [ "Traceback (most recent call last):\n", " my_file_that_uses_the_docusign_api line something", " File \"/var/task/docusign_esign/client/api_client.py\", line 689, in request_jwt_user_token\n token = jwt.encode(payload=claim, key=private_key_bytes, algorithm='RS256').decode(\"utf-8\")\n", "AttributeError: 'str' object has no attribute 'decode'\n"

jazzdev commented 3 years ago

SO says in Python 3 just drop the .decode("utf-8") part.

binyominc commented 3 years ago

@jazzdev I think you're 100% right. The problem is that this is in the api_client of this library and I'm installing it with pip. I could technically pull down the library with git and just put it in my project and take out that line, but as it is in this repo, it's imcompatible with python3.

binyominc commented 3 years ago

Looks like there was a breaking change to pyjwt https://github.com/jpadilla/pyjwt/commit/4770745541363a6a1a1a00b81a64601970df5ce0 see specifically line 82. It no longer is compatible with python 2, which means that the comment @jazzdev made will end up being an issue for anyone who uses this library.

eduardo-marcolino commented 3 years ago

Adding PyJWT==1.7.1 to requirements.txt fix it for me.

binyominc commented 3 years ago

@eduardo-marcolino makes sense. Thanks! I would suggest just to code the specific version of this library too, in case the newer versions of this library are assuming the newer version of PyJWT

harsharahul commented 3 years ago

Hello, The new release of eSign sdk, locks the version to be less than 2.0 for PyJWT package to avoid breaking changes. This should fix issue unless a higher version of the package is already installed or cached in system.

Meanwhile, we are looking to update to a more suitable JWT library for all versions possible.

Thank you all for your help. Appreciate the community's help all around.

gauravdixit007 commented 3 years ago

@harsharahul Hi,

Thanks for looking into this. Any expected date for the new release with support for PyJWT 2.0 I would be happy to create a PR if you don't have the bandwidth. Thanks !!!

Seluj78 commented 2 years ago

Hi, any news for a PyJWT update ? We're using 2.3 in production and the fact that we have to rollback to 1.7 is a pain

aureliendebord commented 2 years ago

Hi, any news for a PyJWT update ? We're using 2.3 in production and the fact that we have to rollback to 1.7 is a pain

Check this comment : https://github.com/docusign/docusign-esign-python-client/issues/135#issuecomment-1023090188