Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
Login programmatically with Django-AllAuth?

Is there a simple way to programmatically login with AllAuth? I don't really care about cookies or sessions, I just want to get a Client that corresponds to an AllAuth user account.

Example:

from django.test import Client
from django.contrib.auth.models import User

user = User.objects.first()  # assuming user registered with AllAuth
client.login(username=user.username)  # password needed!

AllAuth user accounts are not guaranteed to have passwords so the code above won't work. So how can I get the client to login without a password to make testing easier?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use APITestCase's method force_authenticate

class Test(APITestCase):
    def setUp(self):
        self.user = ... #get the user
        self.client.force_authenticate(user=self.user)

Here is the docs

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!