Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'decode' #33

Closed
Datavoore opened this issue Jan 6, 2021 · 7 comments
Closed

AttributeError: 'str' object has no attribute 'decode' #33

Datavoore opened this issue Jan 6, 2021 · 7 comments

Comments

@Datavoore
Copy link

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 ?

@ppawlak
Copy link
Contributor

ppawlak commented Jan 6, 2021

I just tested (with Python 3.8 though) it still works here.

Can you post the result of your pip freeze ?

@ppawlak
Copy link
Contributor

ppawlak commented Jan 6, 2021

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

@Datavoore
Copy link
Author

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 ?

@ppawlak
Copy link
Contributor

ppawlak commented Jan 8, 2021

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.

@ppawlak
Copy link
Contributor

ppawlak commented Jan 8, 2021

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.

@Datavoore
Copy link
Author

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 !

@ppawlak
Copy link
Contributor

ppawlak commented Jan 9, 2021

I have just published version 0.9.0 which pins the library dependencies in setup.py, solving this issue.

Thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants