mardi 4 avril 2017

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?

Aucun commentaire:

Enregistrer un commentaire