Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login with Google redairecting on conformation page to continue Django

I am trying to integrate Google Authentication into my login page. I am working in Django. I have added login with Google Button on my login page, but when I click on that button, I am redirecting to accounts/google/login where it's asking for conformation to continue and menu with sign-in and sign-out.

But what I want is when I click on the button it should ask for accounts to login instead.

This is my login screen: enter image description here

This is what I get on click on the button: enter image description here

this is my button login code in HTML: Login.html:

 {% if user.is_authenticated %}
        <p>Welcome, You are logged in as {{ user.username }}</p>
    {% else %}
        <a href="{% provider_login_url 'google' %}">Login With Google</a>
    {% endif %}

How can I skip this conformation page , it will be glad if anyone can help me out with this thank you.

like image 423
Brijal Kansara Avatar asked Dec 05 '25 06:12

Brijal Kansara


2 Answers

This behavior was released in version 0.47.0:

Added a new setting SOCIALACCOUNT_LOGIN_ON_GET that controls whether or not the endpoints for initiating a social login (for example, “/accounts/google/login/”) require a POST request to initiate the handshake. As requiring a POST is more secure, the default of this new setting is False.

You can add the flag in your settings.py file to avoid the intermediate page:

SOCIALACCOUNT_LOGIN_ON_GET=True

And keep using the latest version of the library.

like image 108
Nicolás Lema Rodríguez Avatar answered Dec 07 '25 03:12

Nicolás Lema Rodríguez


I have uninstalled Django-allauth using the following command :

pip uninstall django-allauth

After that I have installed an older version of that using:

pip install django-allauth==0.45

Then:

python manage.py makemigrations
pytthon manage.py migrate

Done.

like image 25
Brijal Kansara Avatar answered Dec 07 '25 01:12

Brijal Kansara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!