Add token-based login to a Python API so users stay signed in without server-side sessions.
Pass a user's role or permissions to a backend service in a tamper-proof token.
Verify that an incoming API request is from a trusted source using a shared secret key.
Build a simple auth layer for a side project in three lines of Python code.
Install with a single pip command. Encode and decode tokens in three lines of code. No database or server setup required.
PyJWT is a Python library for working with JSON Web Tokens, which are a standard way to pass information securely between two parties. A token is a small, self-contained packet of data, like a user's ID or permissions, that gets signed with a secret key. Any server that knows the secret can verify that the token was not tampered with, which makes them popular for login sessions and API authentication. The library has a straightforward interface. You call one function to create a token from a Python dictionary and a secret key, and another function to decode and verify it. The README shows the full round-trip in three lines of code: encode a dictionary, print the resulting token string, then decode it back to the original dictionary. PyJWT follows RFC 7519, the official specification for JSON Web Tokens. It supports common signing algorithms including HS256, and the full documentation on the readthedocs site covers additional algorithms, validation options, and more advanced configuration. Installation is a single pip command. The README is short and the library is intentionally narrow in scope: it handles token creation and verification, nothing more. Auth0, a company that builds authentication services, sponsors the project and mentions their own Python SDK for teams that want a more complete authentication solution built on top of tokens like these.
← jpadilla on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.