小编Skl*_*n10的帖子

Django Rest Framework JWT

我正在使用Django Rest Framework为我的应用程序构建API,并希望实现DjangoRestFramework-JWT进行令牌认证.这些步骤看起来很简单,但是当我测试端点时,我得到500错误.终端输出是一大堆html说没有提供csrf_token.代码和错误如下.非常感谢您的帮助.

curl -X POST -d "username=admin&password=123abc" http://127.0.0.1:8000/api/token/auth/
Run Code Online (Sandbox Code Playgroud)

CSRF错误

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <meta name="robots" content="NONE,NOARCHIVE">
      <title>403 Forbidden</title>
    </head>
    <body>
        <div id="summary">
            <h1>Forbidden <span>(403)</span></h1>
            <p>CSRF verification failed. Request aborted.</p>
            <p>You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties.</p>
            <p>If you have configured your browser to disable cookies, please re-enable …
Run Code Online (Sandbox Code Playgroud)

python django auth-token jwt django-rest-framework

7
推荐指数
1
解决办法
3497
查看次数

标签 统计

auth-token ×1

django ×1

django-rest-framework ×1

jwt ×1

python ×1