v2.0.0 breaking changes jwt.encode()
See original GitHub issueExpected Result
jwt.encode()
to return an object with a decode
property.
Actual Result
E AttributeError: 'str' object has no attribute 'decode'**
Reproduction Steps
import jwt
from datetime import datetime
secret, algorithm = 'secret', 'hs256'
now = int(datetime.now().timestamp())
payload = {'sub': 'Expiry Test', 'iat': now, 'exp': now + 2}
token = jwt.encode(payload, secret, algorithm=algorithm.upper()).decode()
System Information
$ python -m jwt.help
{
"cryptography": {
"version": "2.8"
},
"implementation": {
"name": "CPython",
"version": "3.8.6"
},
"platform": {
"release": "19.6.0",
"system": "Darwin"
},
"pyjwt": {
"version": "2.0.0"
}
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Changelog — PyJWT 2.6.0 documentation
All notable changes to this project will be documented in this file. ... signing as per RFC7517 #668; Prefer headers[“alg”] to algorithm in...
Read more >ruby-jwt/CHANGELOG.md at main - GitHub
A ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard. ... Change from 1.5.6 to 2.0.0 and appears a "Completed...
Read more >Changelog - hapi.dev
use utf-8 encoding, closes #21 ... Load the JWT from an arbitrary location in the request ... 2.0.0. breaking changes. #11. Require hapi...
Read more >PyJWT - Release 2.6.0 - Read the Docs
4.2.2 Encoding & Decoding Tokens with RS256 (RSA) ... Expiration time is automatically verified in jwt.decode() and raises jwt.
Read more >Firebase JavaScript SDK Release Notes - Google
Changed the networking API to use XHR instead of fetch() for React Native. ... Fixed JWT encoding bug that broke interoperability with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For backwards compatibility,
decode()
should be a method on the class, and simply call.decode_complete()
.In its current form in
v2.0.0
, this is a significant change to this interface and will break a lot of projects.Unrelated to https://github.com/jpadilla/pyjwt/commit/94d102b2e38d09f3c5ec459a8365de8a86c51fe5
jwt.encode(...)
now returns a string instead of a byte string.https://github.com/jpadilla/pyjwt/blob/master/CHANGELOG.md#jwtencode-return-type