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

 ̄綄美尐妖づ 提交于 2020-01-04 12:50:02

问题


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??


回答1:


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.




回答2:


To save someone using the new python-social-auth and django > 1.4

Use this :

{% url 'social:begin' 'twitter' %}


来源:https://stackoverflow.com/questions/15735648/how-can-i-get-google-auth2-authentication-with-extra-scopes-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!