[英]How to use Graphene GraphQL framework with Django REST Framework authentication
[英]How to use GraphQL customized Authentication class?
使用 Django REST Framework(DRF),我可以像這樣自定義Authentication class and Permission class
from django_cognito_jwt import JSONWebTokenAuthentication
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
class CognitoQuestionViewSet(viewsets.ModelViewSet):
authentication_classes = (JSONWebTokenAuthentication,)
permission_classes = (IsAuthenticated,)
queryset = Question.objects.all()
serializer_class = QuestionSerializer
在 GraphQL 文檔中。 它使用與我的項目不同的標准 Django 登錄。 我已經檢查過源LoginRequiredMixin
但沒有運氣。 我在那里看不到Authentication class
然后我可以覆蓋它
問題:
如何像我在DRF
所做的那樣自定義 GraphQL Authentication class and Permission class
經過試驗並嘗試使用django-graphql-jwt
沒有運氣。vinayan3對我的問題有答案。 因為django-cognito-jwt
被認為是DRF
補充。
解決方案:
只需將TokenAuthentication
替換為JSONWebTokenAuthentication
的django_cognito_jwt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.