【问题标题】:django-rest-auth unable to access user details pagedjango-rest-auth 无法访问用户详细信息页面
【发布时间】:2020-03-31 11:43:32
【问题描述】:

我正在使用 django-rest-auth 来验证和注册我的用户,我可以做所有事情。

登录正常 注册正常,但我无法访问获取用户详细信息:

/rest-auth/user/ (GET, PUT, PATCH) 

我正在尝试访问此端点我正在使用 JWT 我得到了正确的令牌。但是当我在 curl 中使用这个命令时:

 curl -X GET http://localhost:8000/rest-auth/user/ -H 'Authorization: Bearer <jwt-toke>'

我收到此错误:

{"detail":"Authentication credentials were not provided."}

我需要做什么才能访问用户的详细信息

【问题讨论】:

    标签: django django-rest-framework django-rest-auth


    【解决方案1】:

    经过长时间的调查,如果您想在 django-rest-auth 中使用 JWT,我能够找到解决方案并根据文档。

    他们分享了一个无效的链接,实际链接是:

    https://jpadilla.github.io/django-rest-framework-jwt/
    

    安装 django-rest-auth 后。

    您需要安装 django-rest-framework-jwt 使用:

    pip install djangorestframework-jwt
    

    如果您想访问此 URL,它将正常工作:

    /rest-auth/user/ (GET, PUT, PATCH) 
    

    您需要传递 JWT 而不是 Bearer 示例:

     curl -X GET http://localhost:8000/rest-auth/user/ -H 'Authorization: JWT <jwt-toke>'
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 2014-11-13
      • 2020-11-16
      • 2021-11-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      相关资源
      最近更新 更多