Skip to content

Instantly share code, notes, and snippets.

@duffn
Created February 13, 2018 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save duffn/178eb725d49998d5d1196eeeb9cb1f0f to your computer and use it in GitHub Desktop.
Save duffn/178eb725d49998d5d1196eeeb9cb1f0f 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