[Answered ]-Logging in using django-social-auth in a django unittest

2👍

It’s not an easy task since the oauth code is very coupled in social-auth. So you really need a oauth service answering.

What I have done is to patch the function social_auth.utils.urlopen with a mock that returns previously recorded answers to trick django-social-auth into thinking it is talking with a real oauth provider.

It’s a really hacky solution but allows me to test my custom social-auth pipeline in an isolated environment.

Leave a comment