docusign-esign-python-client icon indicating copy to clipboard operation
docusign-esign-python-client copied to clipboard

request_jwt_user_token error that can't decode a string

Open binyominc opened this issue 4 years ago • 9 comments

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"

binyominc avatar Dec 22 '20 21:12 binyominc

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

jazzdev avatar Dec 22 '20 23:12 jazzdev

@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 avatar Dec 23 '20 01:12 binyominc

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.

binyominc avatar Dec 23 '20 16:12 binyominc

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

eduardo-marcolino avatar Dec 28 '20 15:12 eduardo-marcolino

@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

binyominc avatar Dec 28 '20 16:12 binyominc

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.

harsharahul avatar Feb 16 '21 19:02 harsharahul

@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 !!!

gauravdixit007 avatar Mar 26 '21 04:03 gauravdixit007

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

Seluj78 avatar Dec 06 '21 15:12 Seluj78

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

aureliendebord avatar Jan 30 '22 16:01 aureliendebord