Closed drippypale closed 3 years ago
Just chiming in to say that I'm facing the exact same situation.
Edit: Just to add, another compatibility issue I found, since this change, jwt.decode
does not allow the verify
argument, so I get this error:
TypeError: decode() got multiple values for argument 'algorithms'
Which is triggered from a call to jwt.decode()
from jwt_decode(token, context=None)
.
As far as I understand, the parameter verify should be removed.
I've had issues with PyJWT 2.0.0 too.
I had to downgrade to 1.7.1
where it was working.
My error was :
in jwt_encode
jwt_settings.JWT_ALGORITHM,
graphql.error.located_error.GraphQLLocatedError: 'str' object has no attribute 'decode'
I did the same thing.
I installed PyJWT v1.7.1
explicitly.
Added pull request #244 as hot-fix. Ideally, jwt usage should be rewritten to make it compatible with the latest PyJWT library.
I wonder if this repo is still active
this is a real problem
Django version 3.1.5, using settings 'app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Traceback (most recent call last):
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\promise\promise.py", line 489, in _resolve_from_executor
executor(resolve, reject)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\promise\promise.py", line 756, in executor
return resolve(f(*args, kwargs))
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql\execution\middleware.py", line 75, in make_it_promise
return next(*args, kwargs)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\decorators.py", line 140, in wrapper
result = f(cls, root, info, kwargs)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\decorators.py", line 129, in wrapper
result = f(cls, root, info, *kwargs)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\decorators.py", line 121, in wrapper
result = f(cls, args, kwargs)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\decorators.py", line 107, in wrapper
return maybe_thenable((context, user, result), on_token_auth_resolve)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphene\utils\thenables.py", line 42, in maybe_thenable
return on_resolve(obj)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\decorators.py", line 70, in on_token_auth_resolve
payload.token = jwt_settings.JWT_ENCODE_HANDLER(payload.payload, context)
File "C:\Users\tony\Anaconda3\envs\server38\lib\site-packages\graphql_jwt\utils.py", line 37, in jwt_encode
return jwt.encode(
graphql.error.located_error.GraphQLLocatedError: 'str' object has no attribute 'decode'
[07/Jan/2021 23:58:23] "POST /graphql/ HTTP/1.1" 200 148
I have modified the function then it worked
I hope this doesn't brake the other functional things, since no need to run decode('utf-8')
@IbrahimAlgadi, it will work for PyJWT >= 2, but not for earlier versions.
@rganeyev
What about classic ( try -- except ) for the str error in the jwt_encode function.
Does it work
@IbrahimAlgadi well, it is bad architecture desicion. What may happen when pyJWT changes signature on their major update? I see here multiple solutions:
@IbrahimAlgadi well, it is bad architecture desicion. What may happen when pyJWT changes signature on their major update? I see here multiple solutions:
- [Easy] Restrict PyJWT version as 1.*. It is hot fix, and will work. #244 for that.
- [Right] Increase PyJWT version to 2.* and fix all jwt-related issues. That includes your change, and all possible jwt usages in the repo.
- [I did this] Abandon this repo as it is dead and no-one is going to maintain it.
Your 3rd choice is actually what I did too. I'm even switching to DRF right now. Graphene-Django seems to be dead too so... I think code owners are all on the new Strawberry project now..
But it doesn't seem to be mature enough for Django,...
Will it be soon ? Will it die like graphene-django did ?
I don't know and I don't wanna know. This was kinda good to use GraphQL and I'm a bit disappointed to lose its benefits but these libraries are not stable enough and I can't predict the future (yet) so I prefer switching to something more reliable, maintained, and widely used.
@fgallese
If you are still interested, I got it working by removing verify=True
option in jwt.decode
method call
https://github.com/ibqn/django-graphql-jwt/commit/dd92319071092bb517187904f3ac0610e8443edf
I apologize for the delay in my response #261. The new release requires Graphene v3 and supports PyJWT>=2:
pip install 'django-graphql-jwt>=0.3.2'
graphql.error.located_error.GraphQLLocatedError: module 'jwt' has no attribute 'ExpiredSignature'
ExpiredSignature
is deprecated andExpiredSignatureError
should be used instead in the newerPyjwt
versions.