The request.user.is_authenticated() is always true unless the requester is the Annonymous user. Are you sure you logged in and that you are the requester before looking at that value?
On Thursday, November 28, 2019 at 8:26:29 AM UTC-5, Eric Gustavsson wrote: > > Hey, > > I've setup mozilla-django-oidc, but I'm struggling to get > `request.user.is_authenticated` to be true within DRF. I added a router > endpoint to the browseable API: > return Response({"authenticated": request.user.is_authenticated()}) > > As well as a response outside DRF: > return HttpResponse(request.user.is_authenticated()) > > After authentication. DRF returns false, outside DRF returns true. > mozilla-django-oidc even has a class extending DRF BasicAuthentication > > https://github.com/mozilla/mozilla-django-oidc/blob/master/mozilla_django_oidc/contrib/drf.py > > Which I added to the DRF settings: > REST_FRAMEWORK = { > # ... > 'DEFAULT_AUTHENTICATION_CLASSES': [ > 'mozilla_django_oidc.contrib.drf.OIDCAuthentication', > ] > } > > This is all using > Django 1.11.15, but I've tested with 2.2 as well. > djangorestframework==3.10.3 > > What am I missing to get a user seen as authenticated within DRF? > > Thanks, > Eric > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/f49aa3b1-f9b8-4a04-bf45-9657944dca74%40googlegroups.com.