Skip to content

WeenSpace/weenspacce-django-jwt

Repository files navigation

Django GraphQL JWT

JSON Web Token authentication for Django GraphQL.
Fantastic documentation is available at https://github.com/WeenSpace/weenspace-django-jwt.

Test Coverage Codacy Package version

Installation

Install last stable version from Pypi:

pip install weenspace-django-jwt

Add AuthenticationMiddleware middleware to your MIDDLEWARE settings:

MIDDLEWARE = [
    # ...
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    # ...
]

Add JWTMiddleware middleware to your GRAPHENE settings:

GRAPHENE = {
    "SCHEMA": "mysite.myschema.schema",
    "MIDDLEWARE": [
        "django_jwt.middleware.JWTMiddleware",
    ],
}

Add JWTBackend backend to your AUTHENTICATION_BACKENDS:

AUTHENTICATION_BACKENDS = [
    "django_jwt.backends.JWTBackend",
    "django.contrib.auth.backends.ModelBackend",
]

Schema

Add weenspace-django-jwt mutations to the root schema:

import graphene
import django_jwt


class Mutation(graphene.ObjectType):
    create_token = django_jwt.Create.Field()
    verify_token = django_jwt.Verify.Field()
    refresh_token = django_jwt.Refresh.Field()


schema = graphene.Schema(mutation=Mutation)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published