Closed ghost closed 7 years ago
@ranvijay-zymr this is not enough information to debug the problem, requests and responses bodies would be very helpful.
I am getting only this error in my console:
[02/Dec/2016 06:58:22]"GET /login/any-oidc/ HTTP/1.1" 302 0
No handlers could be found for logger "social"
ERROR Internal Server Error: /complete/any-oidc/
Traceback (most recent call last):
File "/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 138, in get_response
response = middleware_method(request, e)
File "/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/apps/django_app/middleware.py", line 45, in process_exception
return redirect(url)
File "/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/shortcuts.py", line 116, in redirect
return redirect_class(resolve_url(to, *args, **kwargs))
File "/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/shortcuts.py", line 211, in resolve_url
if '/' not in to and '.' not in to:
TypeError: argument of type 'NoneType' is not iterable
[02/Dec/2016 06:58:34]"GET /complete/any-oidc/?state=gHgDNqsb27ij7uWcPh8FXSFE2ja7iUBr&code=4/Yf6xHAaCGk3v_B9Cd4gKcmuRmVQlyOgIhwjcFiENJ1k&authuser=0&hd=zymr.com&session_state=13bca00e792c51d91ce538cf1efde8b40cb1c402..ab7a&prompt=consent HTTP/1.1" 500 91031
LOGIN_ERROR_URL
in your settings?python-social-auth==0.2.21 LOGIN_ERROR_URL is not defined
You need to define LOGIN_ERROR_URL
, that's the reason for the traceback, that doesn't mean that it will solve the error with your backend, it will just fix the traceback posted above.
you mean to say we need to add a custom view for error like...
middleware.py
class ExampleSocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
def raise_exception(self, request, exception):
return False
def get_message(self, request, exception):
if isinstance(exception, AuthAlreadyAssociated):
return 'Somebody is already using that account!'
return super(ExampleSocialAuthExceptionMiddleware, self) \
.get_message(request, exception)
def get_redirect_uri(self, request, exception):
if request.user.is_authenticated():
return reverse('done')
else:
return reverse('error')
view.py
class AuthError(TemplateView):
template_name = 'error.html'
urls.py
url(r'^error/$', views.AuthError.as_view(), name='error'),
Yeah, that wil do the trick, you can also temporarily set LOGIN_ERROR_URL = '/'
to pass through the exception and continue debugging the OpenId problem.
How will we integrate same with Django rest-framework? In my project, we are using angular for the front end. Here backend port: 8000 and frontend port: 9000 So please tell me how we will redirect back Django standard templates to angular with User(info) valid token.
My code : https://github.com/ranvijay-sachan/psa-common-oidc http://stackoverflow.com/questions/40782251/how-can-we-integrate-any-sso-provider-using-python-social-auth-openid-connect
{"error_message": "AuthCanceled\nAuthentication process canceled\n\n", "error_code": 409, "error_track": "TRACEBACK:\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/core/handlers/base.py\", line 132, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/views/decorators/cache.py\", line 57, in _wrapped_view_func\n response = view_func(request, *args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/django/views/decorators/csrf.py\", line 58, in wrapped_view\n return view_func(*args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/apps/django_app/utils.py\", line 51, in wrapper\n return func(request, backend, *args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/apps/django_app/views.py\", line 28, in complete\n redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/actions.py\", line 44, in do_complete\n user = backend.complete(user=user, *args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/backends/base.py\", line 41, in complete\n return self.auth_complete(*args, **kwargs)\n\n File \"/Users/ranvijay.s/.virtualenvs/env/lib/python2.7/site-packages/social/utils.py\", line 249, in wrapper\n raise AuthCanceled(args[0], response=err.response)\n\n"}