我正在尝试创建一个 flutter 应用程序,它将使用 webview 显示来自我的 Django 应用程序的经过身份验证的数据。
涉及步骤:
我想使用此令牌在 webapp 中登录用户并返回 webview。如果 url 不需要身份验证,它就像一个魅力。当 url 需要身份验证时,我被重定向到登录页面,我希望用户使用已在步骤 1 中获得的令牌身份验证绕过该页面
这是我的 Django 视图。
class QuizTake(FormView):
permission_classes = (IsAuthenticated,)
form_class = QuestionForm
template_name = 'question.html'
result_template_name = 'result.html'
single_complete_template_name = 'single_complete.html'
login_template_name='login.html'
def dispatch(self, request, *args, **kwargs):
self.quiz = get_object_or_404(Quiz, url=self.kwargs['quiz_name'])
print(self.kwargs['quiz_name'])
"""
Authenticate if the request has token authentication
"""
if self.quiz.draft and not request.user.has_perm('quiz.change_quiz'):
raise PermissionDenied
try:
self.logged_in_user = …Run Code Online (Sandbox Code Playgroud) python django django-authentication django-rest-framework django-rest-knox