Answer the question
In order to leave comments, you need to log in
How to treat "WrongBackend" in django-social-auth?
Test application. Registered app in VK. I received an ID and a security key. For hosts, I redirected the domain registered in VK. Then I did it through PuCharm: pip install django-social-auth
In settings.py I added 'social_auth' to INSTALLED_APPS:
INSTALLED_APPS = (
# bla-bla-bla
#...
'social_auth',
)
VK_APP_ID = '12345678' # мой ID для ВКонтакте
VK_API_SECRET = 'ir7HneLl1G8ugtIL1Z3z' # мой защитный ключ для ВКонтакте
AUTHENTICATION_BACKENDS = (
'social_auth.backends.contrib.vk.VKOAuth2Backend', # авторизация чекрез VKontakte
'django.contrib.auth.backends.ModelBackend', # джанговский бэкэнд, иначе войти на сайт по связке пароль&логин будет невозможно.
)
SOCIAL_AUTH_DEFAULT_USERNAME = 'аnonymous'
SOCIAL_AUTH_CREATE_USERS = True
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
)
url(r'', include('social_auth.urls')),
manage.py syncdb
manage.py migrate social_auth
<a href="{% url 'socialauth_begin' 'vkontakte-oauth2' %}">Enter VK</a>
<a href="/login/vkontakte-oauth2/">Enter VK</a>
Exception Type: WrongBackend
Exception Value: Incorrect authentication service "vkontakte-oauth2"
C:\Program Files\Python\2.7\lib\site-packages\social_auth\decorators.py in wrapper
raise WrongBackend(backend)
Traceback (most recent call last):
File "C:\Program Files\Python\2.7\lib\wsgiref\handlers.py", line 86, in run
self.finish_response()
File "C:\Program Files\Python\2.7\lib\wsgiref\handlers.py", line 128, in finish_response
self.write(data)
File "C:\Program Files\Python\2.7\lib\wsgiref\handlers.py", line 212, in write
self.send_headers()
File "C:\Program Files\Python\2.7\lib\wsgiref\handlers.py", line 270, in send_headers
self.send_preamble()
File "C:\Program Files\Python\2.7\lib\wsgiref\handlers.py", line 194, in send_preamble
'Date: %s\r\n' % format_date_time(time.time())
File "C:\Program Files\Python\2.7\lib\socket.py", line 324, in write
self.flush()
File "C:\Program Files\Python\2.7\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] ��������� �� ����� ����-
[15/Aug/2014 19:23:29] "GET /nav/124/31x40/?_=1408116205829 HTTP/1.1" 500 59
Traceback (most recent call last):
File "C:\Program Files\Python\2.7\lib\SocketServer.py", line 595, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python\2.7\lib\SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python\2.7\lib\site-packages\django\core\servers\basehttp.py", line 150, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Program Files\Python\2.7\lib\SocketServer.py", line 653, in __init__
self.finish()
File "C:\Program Files\Python\2.7\lib\SocketServer.py", line 712, in finish
self.wfile.close()
File "C:\Program Files\Python\2.7\lib\socket.py", line 279, in close
self.flush()
File "C:\Program Files\Python\2.7\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] ��������� �� ����� ����-
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59045)
----------------------------------------
Answer the question
In order to leave comments, you need to log in
If you have the latest version of django-social-auth, you need to use another provider for authorization.
Try to replace
<a href="{% url 'socialauth_begin' 'vkontakte-oauth2' %}">Enter VK</a>
on the<a href="{% url 'socialauth_begin' 'vk-oauth' %}">Enter VK</a>
django-social-auth documentation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question