Using django, I am authenticating the user through Google. I get the initial request tokens & redirect the user to google for auth. After which google redirects the user back to my website (using the redirect_url I provide).
At this point the request.user.id
is None
so is request.user.username
why is this happening? I need the user ID to enter the access_tokens (that google sends me) into the DB.
Under what conditions can request.user
object in Django be empty?
UPDATE1: When I get redirected back from Google with the url pattern as http://mywebsite.com/lserv?s=goog
control comes back to my django views function, but django gives me the request.user
object user as Anonymous user with no username or id. why?
UPDATE2:
all this is running on python manage.py runserver
for now...
UPDATE3: Anybody faced anythn similar to this? basically, out of no reason the user
in request
clears out automatically & I get assigned as Anonymous
user. All this happens between url requests from the user (from browser). Why?
Django's auth mechanism has nothing to do with Google's or any other auth service. If you want to integrate third party auth service with your Django site, you should do it youself.
If you're using oauth2 library, it's README has a section named "Logging into Django w/ Twitter" may help you.