How to solve Authentication process canceled error?

北慕城南 提交于 2019-11-30 20:37:33
user6376096

I had exactly the same issue with both Facebook and Google. Have been trying this since yesterday. It is finally working... Have listed my working settings below maybe it will help...

One observation it seems to me that in my case the href values in my login Template had something to do with the issue ??

Hope this helps

SETTINGS.PY
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY='****************.apps.googleusercontent.com'
    SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET ='**************'

    SOCIAL_AUTH_RAISE_EXCEPTIONS = False
    SOCIAL_AUTH_FACEBOOK_KEY = '************' # Facebook App ID
    SOCIAL_AUTH_FACEBOOK_SECRET = '*********************' # Facebook App Secret

INSTALLED_APPS

'social.apps.django_app.default'

TEMPLATES

'context_processors':
social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',

URLS.PY

from django.conf import settings

urlpatterns = [
    url('', include('django.contrib.auth.urls', namespace='auth')),
    url('', include('social.apps.django_app.urls', namespace='social')),

FINALLY THE LOGIN.HTML TEMPLATE, there seemed to be a porblem with origianl href''s

ORIGINAL href was:

<li class="facebook"><a href="{% url 'social:begin' 'facebook' %}">Login with Facebook</a></li>

THIS WAS CHANGED TO

 <li class="facebook"><a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}">Login with Facebook</a></li>

also same change made to href for google.....

IN THE FACBOOK DEVELOPERS CONSOLE

BASIC SETTINGS

APP DOMAINS = mysite.com (also changed the /etc/hosts file to map mysite.com and not localhost to 127.0.0.1)

site url ="example.com:8000/"

ADVANCED SETTINGS ONLY "Allow API Access to App Settings" and "Collect the Apple Advertising Identifier (IDFA) with App Events" are set to YES

all other fields set to no or blank with the exception of the client token field

THE GOOGLE API SETTINGS ARE AS FOLLOWS

"Authorized JavaScript origins" this is left blank

"Authorized redirect URIs" is set to http://example.com:8000/complete/google-oauth2/ (ORIGINALLY I WAS USING http://example.com:8000/social-auth/complete/google-oauth2/)

ON THE "Oauth Consent screen"

"Email address" is set

"Product name shown to users" is set

ALL other fields left at default setting

I had the same problem for a long time. After spending a lot of time, I figured out the problem. For some reason, the document of social-app-django had specified the current version of Facebook API as 2.9(security reasons?). The current version is 2.8. So, just change it to 2.8 or remove it.

SOCIAL_AUTH_FACEBOOK_API_VERSION = '2.8'

This was the reason, my authentication was getting cancelled. Hope this helps !

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