Get user from refresh token in Django Simple JWT's TokenRefreshView

Viewed 386

I am trying to check if the user still exists when Refreshing the Token, returning the user's updated detail (if updated) upon refreshing a token. Is there anyway to retrieve the user's details from the refresh token? [request.user] is currently marked as AnonymousUser so I am unable to know who the refresh token belongs to.

1 Answers

I think it is a good practice to have one endpoint to one type of job. In your case, it will be good to have:

  • endpoint for a token refresh,
  • endpoint to get user details.

Please take a look at Djoser package. It has predefined views and URLs that you can reuse.

If you really want to get some user info on refresh, then you can try to put some user's information in jwt payload part. But I would rather go with to separate endpoints. If user will not exists, then refreshing the token won't return new token.

Related