TokenRefreshView返回状态码500,而不是访问令牌

时间:2020-11-11 10:21:42

标签: python python-3.x django django-rest-framework-simplejwt

According to this Documentation.如果 您想要从刷新令牌中获取新的访问令牌。您需要像这样使用Request方法POST:

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"refresh":"somerefreshtokenhere"}' \
  http://localhost:8000/api/token/refresh/

接下来,每次访问令牌过期时,我依次在django中使用以下代码刷新令牌:

requests.post(url="somekindofurl/refresh-view"
                                             ,headers={"Content-Type": "application/json"},
                                             data={"refresh": variable.refresh_token})

但是, 这将返回状态为500内部服务器错误的完整HTML页面。每当我尝试使用Postman时,它都会成功enter image description here

如您所见,

它将按预期返回访问令牌。请注意,我使用的链接和使用的刷新令牌相同。我不知道是什么原因导致它返回500状态错误。

0 个答案:

没有答案