Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flavors/django-graphql-jwt
JSON Web Token (JWT) authentication for Graphene Django
https://github.com/flavors/django-graphql-jwt
authentication django graphene graphql jsonwebtoken jwt oauth2 token
Last synced: 1 day ago
JSON representation
JSON Web Token (JWT) authentication for Graphene Django
- Host: GitHub
- URL: https://github.com/flavors/django-graphql-jwt
- Owner: flavors
- License: mit
- Created: 2017-11-05T15:29:56.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2023-12-20T11:55:00.000Z (about 1 year ago)
- Last Synced: 2024-05-17T08:42:29.985Z (7 months ago)
- Topics: authentication, django, graphene, graphql, jsonwebtoken, jwt, oauth2, token
- Language: Python
- Homepage: https://django-graphql-jwt.domake.io
- Size: 1.09 MB
- Stars: 814
- Watchers: 15
- Forks: 170
- Open Issues: 67
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- License: LICENSE
- Authors: AUTHORS.rst
Awesome Lists containing this project
- awesome-starred-test - flavors/django-graphql-jwt - JSON Web Token (JWT) authentication for Graphene Django (Python)
README
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:
```sh
pip install django-graphql-jwt
```Add `AuthenticationMiddleware` middleware to your *MIDDLEWARE* settings:
```py
MIDDLEWARE = [
# ...
"django.contrib.auth.middleware.AuthenticationMiddleware",
# ...
]
```Add `JSONWebTokenMiddleware` middleware to your *GRAPHENE* settings:
```py
GRAPHENE = {
"SCHEMA": "mysite.myschema.schema",
"MIDDLEWARE": [
"graphql_jwt.middleware.JSONWebTokenMiddleware",
],
}
```Add `JSONWebTokenBackend` backend to your *AUTHENTICATION_BACKENDS*:
```py
AUTHENTICATION_BACKENDS = [
"graphql_jwt.backends.JSONWebTokenBackend",
"django.contrib.auth.backends.ModelBackend",
]
```## Schema
Add *django-graphql-jwt* mutations to the root schema:
```py
import graphene
import graphql_jwtclass 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)
```