Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda