jazzband / django-rest-knox

Authentication Module for django rest auth
MIT License
1.17k stars 213 forks source link

Endpoint for retrieving user by posting token #247

Closed csanders7070 closed 4 months ago

csanders7070 commented 3 years ago

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

psibean commented 3 years ago

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

csanders7070 commented 3 years ago

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 .

AlexCernik commented 3 years ago

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