Created
February 13, 2018 18:03
-
-
Save duffn/178eb725d49998d5d1196eeeb9cb1f0f to your computer and use it in GitHub Desktop.
django-graphene JWT authorization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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