我正在使用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."}要访问用户的详细信息,我需要做什么?
发布于 2019-12-06 18:36:05
经过长时间的调查,如果您想在django-rest-auth中使用JWT,我可以找到一个解决方案,并根据文档。
他们共有一个不起作用的链接,即:
https://jpadilla.github.io/django-rest-framework-jwt/在安装django-rest-auth之后。
您需要使用以下方法安装django-rest-framework:
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>'对我来说很管用。
https://stackoverflow.com/questions/59213844
复制相似问题