我正在使用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."}
要访问用户的详细信息我需要做什么
答案 0 :(得分: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>'
对我有用。