You can check this documentation on `Read the Docs`_ too.
-For Russian services backends (Yandex, Mail.ru, etc.) see http://www.ikrvss.ru/tag/django-social-auth/
-
.. contents:: Table of Contents
-
Demo
----
* `Skyrock OAuth`_
* `Yahoo OAuth`_
* `Evernote OAuth`_
+ * `Mail.ru OAuth`_
+ * `Odnoklassniki OAuth`_
- Basic user data population and signaling, to allows custom fields values
from providers response
See the `names of the privileges VKontakte`_.
+You can also use Vkontakte's own OpenAPI to log in, but you need to provide a HTML template
+with JavaScript code to authenticate. See vkontakte.html in templates folder for details.
+
+To support authentication for VKontakte applications see `authentication for VKontakte applications`_.
+
MSN Live Connect
^^^^^^^^^^^^^^^^
EVERNOTE_CONSUMER_KEY = ''
EVERNOTE_CONSUMER_SECRET = ''
+Yandex OAuth and OpenID
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Yandex uses OAuth 2.0 workflow, fill and YANDEX_APP_ID and YANDEX_API_SECRET settings to log in.
+Currently there are 2 backends for Yandex, one is Yaru to log in using Ya.ru service and another one is
+YandexOAuth that could use service API from settings. Use YANDEX_OAUTH2_API_URL to set up which service to use.
+Tested with 'https://api-yaru.yandex.ru/me/' for Ya.ru and 'http://api.moikrug.ru/v1/my/' for Moi Krug.
+
+Yandex also uses OpenID 2.0. You do not need to provide user's name because Yandex will do it for you.
+
+Mail.ru OAuth
+^^^^^^^^^^^^^
+
+Mail.ru uses OAuth2 workflow, to use it fill in settings
+
+MAILRU_OAUTH2_CLIENT_KEY = ''
+MAILRU_OAUTH2_APP_KEY = ''
+MAILRU_OAUTH2_CLIENT_SECRET = ''
+
+Odnoklassniki.ru
+^^^^^^^^^^^^^^^^
+
+Odnoklassniki.ru uses OAuth2 workflow, to use it fill in settings
+
+ODNOKLASSNIKI_OAUTH2_CLIENT_KEY = ''
+ODNOKLASSNIKI_OAUTH2_APP_KEY = ''
+ODNOKLASSNIKI_OAUTH2_CLIENT_SECRET = ''
Testing
-------
- krvss_ (Stas Kravets):
- Initial setup.py configuration
+ - LiveJournal support
+ - Mail.ru, Odnoklassniki support
+ - Yandex OpenID support
+ - VKontakte OpenAPI support
- jezdez_ (Jannis Leidel):
.. _Yahoo Developer Center: https://developer.apps.yahoo.com/projects/
.. _Evernote API Key form: http://dev.evernote.com/support/api_key.php
.. _hassek: https://github.com/hassek
+.. _Mail.ru OAuth: http://api.mail.ru/docs/guides/oauth/
+.. _Odnoklassniki OAuth: http://dev.odnoklassniki.ru/wiki/display/ok/The+OAuth+2.0+Protocol
+.. _authentication for VKontakte applications: http://www.ikrvss.ru/2011/11/08/django-social-auh-and-vkontakte-application/
\ No newline at end of file
GOOGLE_WHITE_LISTED_EMAILS = ['me@mygoogleappsdomain.com', 'you@gmail.com']
-Google OpenID
--------------
-
-Configurable settings:
-
-- Supply a list of domain strings to be checked. The default (empty list) allows all domains. If a list is provided and a user attempts to sign in with a Google account that is not in the list, then a ValueError will be raised and the user will be redirected to your login error page::
-
- GOOGLE_WHITE_LISTED_DOMAINS = ['mydomain.com']
-
-
Orkut
-----
See the `names of the privileges VKontakte`_.
+You can also use Vkontakte's own OpenAPI to log in, but you need to provide HTML template
+with JavaScript code to authenticate. See vkontakte.html in templates folder for details.
+
+To support authentication for VKontakte applications see `authentication for VKontakte applications`_
+
.. _Vkontakte OAuth: http://vk.com/developers.php?oid=-1&p=%D0%90%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2
.. _names of the privileges VKontakte: http://vk.com/developers.php?oid=-1&p=%D0%9F%D1%80%D0%B0%D0%B2%D0%B0_%D0%B4%D0%BE%D1%81%D1%82%D1%83%D0%BF%D0%B0_%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9
.. _Vkontakte API: http://vk.com/developers.php
+.. _authentication for VKontakte applications: http://www.ikrvss.ru/2011/11/08/django-social-auh-and-vkontakte-application/
\ No newline at end of file
SOCIAL_AUTH_LOGIN_REDIRECT_URL
SOCIAL_AUTH_INACTIVE_USER_URL
-- The app catches any exception and logs errors to ``logger`` or
- ``django.contrib.messagess`` app. Having tracebacks is really useful when
- debugging, for that purpose this setting was defined::
-
- SOCIAL_AUTH_RAISE_EXCEPTIONS = DEBUG
-
- It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid
- tracebacks when ``DEBUG = True``.
.. _Model Manager: http://docs.djangoproject.com/en/dev/topics/db/managers/#managers
.. _Login URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-url
from social_auth import __version__ as version
from social_auth.utils import setting
+
def home(request):
"""Home view, displays login mechanism"""
if request.user.is_authenticated():
+django>=1.2.5
oauth2>=1.5.167
python_openid>=2.2
'social_auth.backends.pipeline'],
package_data={'social_auth':['locale/*/LC_MESSAGES/*']},
long_description=long_description(),
- install_requires=['oauth2>=1.5.167',
+ install_requires=['django>=1.2.5',
+ 'oauth2>=1.5.167',
'python_openid>=2.2'],
- classifiers=['Framework :: Django',
+ classifiers=['Framework :: Django',
'Development Status :: 4 - Beta',
'Topic :: Internet',
'License :: OSI Approved :: BSD License',
from django.contrib import messages
from django.views.decorators.csrf import csrf_exempt
-from social_auth.utils import sanitize_redirect, setting,\
- backend_setting, clean_partial_pipeline
+from social_auth.utils import sanitize_redirect, setting, \
+ backend_setting, clean_partial_pipeline
from social_auth.decorators import dsa_view
-DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or\
+DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \
setting('LOGIN_REDIRECT_URL')
LOGIN_ERROR_URL = setting('LOGIN_ERROR_URL', setting('LOGIN_URL'))
return user
else:
url = backend_setting(backend,
- 'SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL') or\
- redirect_value or\
+ 'SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL') or \
+ redirect_value or \
DEFAULT_REDIRECT
return HttpResponseRedirect(url)
def disconnect(request, backend, association_id=None):
"""Disconnects given backend from current logged in user."""
backend.disconnect(request.user, association_id)
- url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or\
- backend_setting(backend, 'SOCIAL_AUTH_DISCONNECT_REDIRECT_URL') or\
+ url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or \
+ backend_setting(backend, 'SOCIAL_AUTH_DISCONNECT_REDIRECT_URL') or \
DEFAULT_REDIRECT
return HttpResponseRedirect(url)
return HttpResponseRedirect(backend.auth_url())
else:
return HttpResponse(backend.auth_html(),
- content_type='text/html;charset=UTF-8')
+ content_type='text/html;charset=UTF-8')
def complete_process(request, backend, *args, **kwargs):
# in authenticate process
social_user = user.social_user
if redirect_value:
- request.session[REDIRECT_FIELD_NAME] = redirect_value or\
+ request.session[REDIRECT_FIELD_NAME] = redirect_value or \
DEFAULT_REDIRECT
if setting('SOCIAL_AUTH_SESSION_EXPIRATION', True):
# store last login backend name in session
key = setting('SOCIAL_AUTH_LAST_LOGIN',
- 'social_auth_last_login_backend')
+ 'social_auth_last_login_backend')
request.session[key] = social_user.provider
# Remove possible redirect URL from session, if this is a new
# account, send him to the new-users-page if defined.
new_user_redirect = backend_setting(backend,
- 'SOCIAL_AUTH_NEW_USER_REDIRECT_URL')
+ 'SOCIAL_AUTH_NEW_USER_REDIRECT_URL')
if new_user_redirect and getattr(user, 'is_new', False):
url = new_user_redirect
else:
- url = redirect_value or\
+ url = redirect_value or \
backend_setting(backend,
- 'SOCIAL_AUTH_LOGIN_REDIRECT_URL') or\
+ 'SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \
DEFAULT_REDIRECT
else:
url = backend_setting(backend, 'SOCIAL_AUTH_INACTIVE_USER_URL',
- LOGIN_ERROR_URL)
+ LOGIN_ERROR_URL)
else:
msg = setting('LOGIN_ERROR_MESSAGE', None)
if msg:
if request.session.get(name):
data = request.session.pop(name)
idx, args, kwargs = backend.from_session_dict(data, user=user,
- request=request,
- *args, **kwargs)
+ request=request,
+ *args, **kwargs)
return backend.continue_pipeline(pipeline_index=idx, *args, **kwargs)
else:
return backend.auth_complete(user=user, request=request, *args,
- **kwargs)
\ No newline at end of file
+ **kwargs)