AttributeError: 'str' object has no attribute 'decode'
Datavoore opened this issue · comments
Hello,
I have been using this library without issue for a few months. I started encountering an issue since this january 1st.
I'm using the same exact environment and credentials but here is the stacktrace of the exception I am now running into :
AttributeError: 'str' object has no attribute 'decode'
File "batch_reporting.py", line 48, in lambda_handler
issuer_id)
File "appstoreconnect/api.py", line 51, in init
token = self.token # generate first token
File "appstoreconnect/api.py", line 269, in token
self._token = self._generate_token()
File "appstoreconnect/api.py", line 65, in _generate_token
headers={'kid': self.key_id, 'typ': 'JWT'}, algorithm=ALGORITHM).decode('ascii')
The python version is 3.6 and I am using the last version of the library 0.8.4
Do you have any lead on what might cause this ?
I just tested (with Python 3.8 though) it still works here.
Can you post the result of your pip freeze
?
I suspect your version of PyJWT not being correct. It should be 1.6.4
I just tested with the latest version 2.0.0, and jwt.encode()
retruns an str
whereas 1.6.4 returns bytes
Yes I just came to the same conclusion. Thanks for taking the time ! Are you interested in PR to protect against this behavior from PyJWT ?
Are you interested in PR to protect against this behavior from PyJWT
Sure!
https://github.com/Ponytech/appstoreconnectapi/blob/master/requirements.txt pins PyJWT to 1.6.4 but https://github.com/Ponytech/appstoreconnectapi/blob/master/setup.py#L18 does not pin the dependency.
I am sure there is some way to take dependencies from requirements.txt
instead of writing them twice.
I am sure there is some way to take dependencies from requirements.txt instead of writing them twice.
After some research I found out you can put your dependencies in setup.py
and just put a simple dot in requirements.txt
.
The other way around (parsing the equirements.txt in setup.py) is not recommended.
I will do this shortly.
Oh that's why !
Indeed that's what I saw too.
That's nice, I will be able to get rid of the fixed version in my code. Thanks for your responsiveness !
I have just published version 0.9.0 which pins the library dependencies in setup.py, solving this issue.
Thanks for reporting it!