JSON Web Token authentication for Django GraphQL.
Fantastic documentation is available at https://django-graphql-jwt.domake.io.
Installation
Install last stable version from Pypi:
pip install django-graphql-jwt
Add AuthenticationMiddleware middleware to your MIDDLEWARE settings:
MIDDLEWARE = [
# ...
"django.contrib.auth.middleware.AuthenticationMiddleware",
# ...
]
Add JSONWebTokenMiddleware middleware to your GRAPHENE settings:
GRAPHENE = {
"SCHEMA": "mysite.myschema.schema",
"MIDDLEWARE": [
"graphql_jwt.middleware.JSONWebTokenMiddleware",
],
}
Add JSONWebTokenBackend backend to your AUTHENTICATION_BACKENDS:
AUTHENTICATION_BACKENDS = [
"graphql_jwt.backends.JSONWebTokenBackend",
"django.contrib.auth.backends.ModelBackend",
]
Schema
Add django-graphql-jwt mutations to the root schema:
import graphene
import graphql_jwt
class Mutation(graphene.ObjectType):
token_auth = graphql_jwt.ObtainJSONWebToken.Field()
verify_token = graphql_jwt.Verify.Field()
refresh_token = graphql_jwt.Refresh.Field()
schema = graphene.Schema(mutation=Mutation)
Metadata
Release files for django-graphql-jwt 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_graphql_jwt-0.4.0.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_graphql_jwt-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 67.7 kB
Release files / django_graphql_jwt-0.4.0.tar.gz
| Download URL | django_graphql_jwt-0.4.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
537972519f0deeec7a0e4a306ddfed1fe385266ef61c9f78c54cd04ac01a171e
|
|
BLAKE2b-256 checksum How to use checksums |
a8446781e0ef4438f9f8b8b0fc39d4e874659b555bc57159243faee99c66483e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / django_graphql_jwt-0.4.0-py3-none-any.whl
| Download URL | django_graphql_jwt-0.4.0-py3-none-any.whl |
|---|---|
| Size | 47.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5823aa8ac9bf0b7a6e3b2febd029598b332c41fe9043d89900c116fcecd23f5e
|
|
BLAKE2b-256 checksum How to use checksums |
96829b6e9425515ccec08894f3dbdd2b439244859c5516777a576b929eb6f854
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|