jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
5.08k stars 679 forks source link

PyJWT does not support all valid JSON types as the payload. #783

Closed teaishealthy closed 1 year ago

teaishealthy commented 2 years ago

PyJWT does not support all valid JSON types as the payload.

Expected Result

strs, ints, floats and lists (even better Sequences) should be able to encoded in the payload of the JWT as they are valid JSON types (string, number, object and array)

Actual Result

Raises TypeError: Expecting a mapping object, as JWT only supports JSON objects as payloads.

Reproduction Steps

import jwt
jwt.encode(123, "secret", algorithm="HS256")

System Information

{
  "cryptography": {
    "version": ""
  },
  "implementation": {
    "name": "CPython",
    "version": "3.10.4"
  },
  "platform": {
    "release": "5.10.16.3-microsoft-standard-WSL2",
    "system": "Linux"
  },
  "pyjwt": {
    "version": "2.4.0"
  }
}
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days