django-rest-knox icon indicating copy to clipboard operation
django-rest-knox copied to clipboard

Endpoint for retrieving user by posting token

Open csanders7070 opened this issue 3 years ago • 3 comments

Hello,

I am trying to find a way to retrieve the user information by posting the token provided by django-knox to some endpoint. I know that I can do the opposite (post user information and get token to pass into headers, etc.), but I can't find anyway to retrieve the user information if all I have is the valid django-knox token. Thanks for the help

christian

csanders7070 avatar Apr 07 '21 17:04 csanders7070

You should be able to just serialize request.user which will be your default user model, just ensure you only include the information you want to send back, e.g. no password

psibean avatar Apr 27 '21 09:04 psibean

Thanks so much. That worked exactly as I wanted. Sorry, that was simpler than I thought.

cas

On Tue, Apr 27, 2021 at 2:52 AM Psi @.***> wrote:

You should be able to just serialize request.user which will be your default user model, just ensure you only include the information you want to send back, e.g. no password

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/James1345/django-rest-knox/issues/247#issuecomment-827476199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMKRROV4Q5WKCABNFVNDHSLTK2CMRANCNFSM42RGZL6Q .

csanders7070 avatar Apr 27 '21 15:04 csanders7070

How to create a function to check if user is authenticated??

AlexCernik avatar Nov 12 '21 15:11 AlexCernik