Skip to main content

JSON Web Token for Django REST and GraphQL.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weenspace_django_jwt-1.0.1.tar.gz (21.9 kB view hashes)

Uploaded Source

Built Distribution

weenspace_django_jwt-1.0.1-py3-none-any.whl (47.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page