def login(request, provider):
    if not isinstance(request.user, AnonymousUser):
        return redirect(settings.LOGIN_REDIRECT_URL)

    if 'code' not in request.GET:
        return _redirect(request, provider)
    else:
        return _login(request, provider)
Log in the current user following the OAuth 2.0 server flow
dataset/ETHPy150Open demianbrecht/django-sanction/django_sanction/views.py/login