Replies: 1 comment
-
Turns out, the problem was that I didn't implement get_user in my auth backend, so the function from BaseBackend was being called, which always returns None. After implementing the function, the log in seems to be working as expected :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I want to implement user authentication using a third-party website API (Last.FM). Upon successful authentication, the website redirects the user to a callback URL in my app with a query parameter containing a user token. In this endpoint I want to log the user in using django session, so they can be authenticated in any other endpoint from that point.
I previously implemented this using a regular django view, like below:
I want to know if it's possible to replace this view with a ninja API endpoint. So far I've tried the following:
However it seems that the session is not being stored. The user retrieved from auth.authenticate is only present for this request, but when I navigate to any other page (ie. regular views like django admin or ninja API endpoints with django_auth authentication enabled), the user is not authenticated anymore. Looks like auth.login(request, user) isn't doing anything. Is there some other way I could achieve this from the API endpoint, or do I have to go back to using a regular view?
Beta Was this translation helpful? Give feedback.
All reactions