Search code examples
djangooauth-2.0django-socialauth

How can I get Google Auth2 authentication with Extra Scopes to work?


I've set up my Django social auth according to the documentation. With the following:

GOOGLE_OAUTH_EXTRA_SCOPE = ['https://www.googleapis.com/auth/calendar']
GOOGLE_OAUTH2_CLIENT_ID      = *client id here*
GOOGLE_OAUTH2_CLIENT_SECRET  = *client secret here*

In the API console, I have set it to a web application with the Redirect URI as omab says:

http://localhost:8000/complete/google-oauth2/

In my template I have:

<a href="{% url socialauth_begin 'google' %}" class="google_login_button">Login with Google </a>

However, when I test the application the oAuth doesn't ask for "calendar permissions", just the default email ones.

What am I missing??


Solution

  • After some searching, it was a silly mistake. The link should be:

    {% url socialauth_begin 'google-oauth2' %}

    I misinterpreted the documentation when it said write in the name of whatever is in the backend.

    Hope this helps future people.