-
-
Save klebercode/dd9d2542bb0184dbea9f7b999b8cf5b6 to your computer and use it in GitHub Desktop.
django-graphene JWT authorization
This file contains 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