django-allauth redirect confirm page

288 views Asked by At

I have an app on DJango. In the login part I have implemented authentication with Microsoft using DJango allatuh. When I press the "sign in" button with microsoft, before redirecting to the microsof, it redirects me to a page where I have to press the "continue" button. I want to remove this second page so that it automatically redirects me to the microsoft page. I have this on my "settings.py" file:

SOCIALACCOUNT_PROVIDERS = {
    'microsoft': {
        'APP': {
            'client_id': '',
            'secret': '',
        },
        'SCOPE': ['User.Read'],
        'AUTH_PARAMS': {
            'prompt': 'select_account',
        },
        'INIT_PARAMS': {
            'prompt': 'select_account',
        },
        'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
    },
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False

I don't know what to change

2

There are 2 answers

2
Tech On BEST ANSWER

You can use this code for bypass that confirmation page:

<form method="post" action="{% url 'microsoft_login' %}">
            {% csrf_token %}
            <button type="submit" class="btn">
             Login with Microsoft
            </button>
</form>

instead of:

 {% provider_login_url 'microsoft' %}
2
biscuit_delicious On

Instead of 'prompt': 'select_account', you could use 'prompt': 'none'

SOCIALACCOUNT_PROVIDERS = {
    'microsoft': {
        'APP': {
            'client_id': '',
            'secret': '',
        },
        'SCOPE': ['User.Read'],
        'AUTH_PARAMS': {
            'prompt': 'none',
        },
        'INIT_PARAMS': {
            'prompt': 'none',
        },
        'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
    },
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False