Skip to content

Instantly share code, notes, and snippets.

@klebercode
Forked from duffn/urls.py
Created September 27, 2018 00:04
Show Gist options
  • Save klebercode/dd9d2542bb0184dbea9f7b999b8cf5b6 to your computer and use it in GitHub Desktop.
Save klebercode/dd9d2542bb0184dbea9f7b999b8cf5b6 to your computer and use it in GitHub Desktop.
django-graphene JWT authorization
# Authorization with django-graphene
# using django-jwt-auth==0.0.2
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView
from jwt_auth.mixins import JSONWebTokenAuthMixin
class AuthGraphQLView(JSONWebTokenAuthMixin, GraphQLView):
"""Graphene view with JWT authentication."""
pass
urlpatterns = [
url(
regex=r'^$',
view=csrf_exempt(AuthGraphQLView.as_view(graphiql=True)),
name='graphql'
),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment