如何解决认证过程取消错误? [英] How to solve Authentication process canceled error?
问题描述
现在我尝试设置python-social-app
在Facebook登录后,用户名/密码重定向到错误页面,我不知道为什么会发生这种情况..
在我的设置中,我有'social.backends.facebook.FacebookOAuth2'
,我正确设置 SOCIAL_AUTH_FACEBOOK_KEY
和秘密,所以真的在哪里看错误?
追溯
环境:
请求方法:GET
请求URL:http://website.com:8000/complete/facebook/ ?redirect_state = IuQDEiyX2bbS8Uhk7MR3hpRFLNZlW2Y5&安培;代码= AQDH5kqBibfy9bi21M9tTieujRAqvJVYdAb2UPFvfH6DVXoCWrrtamRA99Ze5-6cC6qHPiNq-a3XbGh2Gg4pbdFfM4OTpCEpWkPID6SZrHfAoEan8Q68cV17LDgsryX_M45QoXd0knpbE0x-QwAPwdoFmKQGHLw7xomCHeN5pCtrWhtoYQIrsFE1UQZZaxt4qtLzAmfmCRjDO7Et_S75fngLiomM0PfevTChLbHJHMYaqy6DBkgGZqZK-bXrqLaNFnBEoZ3M956DwCg4ZtTnvxulR4sXH9ZV3IoxVhL0JxMVsGnT2H_0wdKujIDPKcdPKZc&安培;状态= IuQDEiyX2bbS8Uhk7MR3hpRFLNZlW2Y5
Django的版本:1.8.3
PY thon版本:2.7.6
已安装的应用程序:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes'
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'frontend',
'social .apps.django_app.default')
安装的中间件:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib .messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
追溯:
文件/Users/simon/Freelancer/env/lib/python2.7/site-packages/django/core/handlers/base.p yin get_response
132. response = wrapped_callback(request,* callback_args,** callback_kwargs)
文件/Users/simon/Freelancer/env/lib/python2.7/site-packages/django/ _wrapped_view_func
中的views / decorators / cache.py。57. response = view_func(request,* args,** kwargs)
文件/Users/simon/Freelancer/env/lib/python2.7/返回view_func(* args,** kwargs)
文件/ Users / simon / Freelancer / env / lib / python2中的包装/ django / views / decorators / csrf.py
51.返回func(request,backend,* args,** kwargs)
文件/ Users / simon /完成
中的自由职业者/ env / lib / python2.7 / site-packages / social / apps / django_app / views.py 28. redirect_name = REDIRECT_FIELD_NAME,* args,** kwargs)
文件/用户/ simon / Freelancer / env / lib / python2.7 / site-packages / social / actions.pyin do_complete
43. user = backend.compl ete(user = user,* args,** kwargs)
完整的$ b文件/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/backends/base.py $ b 41. return self.auth_complete(* args,** kwargs)
文件/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/utils.pyin wrapper
232. raise AuthCanceled(args [0])
异常类型:AuthCanceled at / complete / facebook /
异常值:认证过程已取消
我和Facebook和Google完全一样的问题。
自昨天以来一直在尝试。
它终于工作了...
列出了我下面的工作设置可能会帮助...
在我看来,有一个观察在我的情况下,我的登录模板中的href值与问题有关?
希望这有帮助
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 Secre
t
INSTALLED_APPS
'social.apps.django_app.default'
TEMPLATES
'context_processors':
social.apps.django_app.context_processors.backends',
'social.apps .django_a pp.context_processors.login_redirect',
URLS.PY
从django.conf导入设置
/ pre>
urlpatterns = [
url('',include('django.contrib.auth.urls' ,namespace ='auth')),
url('',include('social.apps.django_app.urls',namespace ='social')),
FINALLY LOGIN.HTML TEMPLATE,似乎有一个porblem与origianl href'的
ORIGINAL href是:
< li class =facebook>< a href ={%url'social :begin''facebook'%}>使用Facebook登录< / a>< / li>
此项更改为
< li class =facebook>< a href ={%url'social:begin''facebook'%}?next = {{request.path}}>登录与Facebook< / a>< / li>
同样的更改为href为谷歌.....
在FACBOOK开发者控制台
基本设置
APP DOMAINS = mysite.com (也更改/ etc / hosts文件将mysite.com映射到localhost到127.0.0.1)
site url =example.com:8000 /
高级设置
ONLY
允许API访问应用程序设置和收集苹果广告标识符(IDFA)与应用程序事件设置为YES
除客户端令牌字段外,所有其他字段设置为no或空白
GOOGLE API设置如下所示
授权JavaScript起始 p>
授权重定向URI设置为 http ://example.com:8000 / complete / google-oauth2 /
(ORIGINA LLY我使用 http://example.com:8000/social-auth/完成/ google-oauth2 / )
在Outh同意屏幕
电子邮件地址
设置
向用户显示的产品名称
设置
所有其他字段保留默认设置
Now I try to setup python-social-app
In facebook login after the username/password redirect to error page I don't know why this happen...
In my setting I have
'social.backends.facebook.FacebookOAuth2'
and I correctly setSOCIAL_AUTH_FACEBOOK_KEY
and Secret so Really where to look the error.?Traceback
Environment: Request Method: GET Request URL: http://website.com:8000/complete/facebook/?redirect_state=IuQDEiyX2bbS8Uhk7MR3hpRFLNZlW2Y5&code=AQDH5kqBibfy9bi21M9tTieujRAqvJVYdAb2UPFvfH6DVXoCWrrtamRA99Ze5-6cC6qHPiNq-a3XbGh2Gg4pbdFfM4OTpCEpWkPID6SZrHfAoEan8Q68cV17LDgsryX_M45QoXd0knpbE0x-QwAPwdoFmKQGHLw7xomCHeN5pCtrWhtoYQIrsFE1UQZZaxt4qtLzAmfmCRjDO7Et_S75fngLiomM0PfevTChLbHJHMYaqy6DBkgGZqZK-bXrqLaNFnBEoZ3M956DwCg4ZtTnvxulR4sXH9ZV3IoxVhL0JxMVsGnT2H_0wdKujIDPKcdPKZc&state=IuQDEiyX2bbS8Uhk7MR3hpRFLNZlW2Y5 Django Version: 1.8.3 Python Version: 2.7.6 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'frontend', 'social.apps.django_app.default') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware') Traceback: File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view 58. return view_func(*args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper 51. return func(request, backend, *args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/apps/django_app/views.py" in complete 28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/actions.py" in do_complete 43. user = backend.complete(user=user, *args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/backends/base.py" in complete 41. return self.auth_complete(*args, **kwargs) File "/Users/simon/Freelancer/env/lib/python2.7/site-packages/social/utils.py" in wrapper 232. raise AuthCanceled(args[0]) Exception Type: AuthCanceled at /complete/facebook/ Exception Value: Authentication process canceled
解决方案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 Secre
t
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
这篇关于如何解决认证过程取消错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!