question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'dict' object has no attribute '_jws'

See original GitHub issue

AttributeError: ‘dict’ object has no attribute ‘_jws’

got this error :

File “E:\github\MyGits\TDA\rest_server_sql.py”, line 113, in login token = jwt.JWT.encode({‘public_id’ : user.public_id, ‘exp’ : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)}, app.config[‘SECRET_KEY’]) File “E:\github\MyGits\TDA\venv_tda\lib\site-packages\jwt\jwt.py”, line 44, in encode return self._jws.encode(message, key, alg, optional_headers) AttributeError: ‘dict’ object has no attribute ‘_jws’

while generating token: token = jwt.JWT.encode({'public_id' : user.public_id, 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)}, app.config['SECRET_KEY'])

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
yosida95commented, Aug 20, 2018

It’s a caller bug. jwt.JWT.encode is not a static method, you should instantiate jwt.JWT class first and then call encode method of that instance.

1reaction
nwoowcommented, Aug 12, 2020

@yosida95 anyway I fixe the problem by uninstalling using :

pip uninstall jwt==1.0.0

And then I uninstalled pyJWT using:

pip uninstall PyJWT

And then install it again:

pip install PyJWT

And my code:

encoded = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')

Is working

Read more comments on GitHub >

github_iconTop Results From Across the Web

FastAPI is returning AttributeError: 'dict' object has no attribute ...
The problem happens when you try to create the Response object. This object expects a string as input (infact it tries to call...
Read more >
Scipy | AttributeError: 'dict' object has no attribute 'norm' - Reddit
Hello everyone! I'm trying to use scipy's stats.norm.pdf() to build a gaussian model of my data, but I'm getting the error above.
Read more >
python tutorial: AttributeError: 'dict' object has no attribute 'value'
python tutorial: #codefix # python #python_tutorialAttributeError: ' dict ' object has no attribute 'value': In this video i have shared why ...
Read more >
How to fix : dict object has no attribute iteritems - YouTube
dict object has no attribute iteritems it is Attribute error in Python caused by removal of iteritems methods in Python 3.x.
Read more >
JWCrypto Documentation - Read the Docs
It fails for a JWK that has only a public key or is symmetric. Parameters as_dict(bool) – If set to True export as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found