From: Matías Aguirre Date: Sun, 6 Mar 2011 14:21:04 +0000 (-0200) Subject: LinkedIn Support from Quard. Closes gh-34 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=a4c65504d8d63d11180f61fb91298b6f0c0258f5;p=django-social-auth.git LinkedIn Support from Quard. Closes gh-34 --- diff --git a/README.rst b/README.rst index 32f5b8e..900e45e 100644 --- a/README.rst +++ b/README.rst @@ -10,6 +10,13 @@ implements a common interface to define new authentication providers from third parties. +----- +Demo +----- +There's a demo at http://social.matiasaguirre.net/. +Note: It lacks Orkut support at the moment. + + -------- Features -------- @@ -57,9 +64,17 @@ Dependencies that *must* be meet to use the application: Installation ------------ -Clone from github_:: +From pypi_:: + + $ pip install django-social-auth + +or:: + + $ easy_install django-social-auth + +or clone from github_:: - $ git clone git://github.com/Quard/django-social-auth.git + $ git clone git://github.com/omab/django-social-auth.git and add social_auth to PYTHONPATH:: @@ -89,7 +104,7 @@ Configuration 'social_auth.backends.google.GoogleOAuthBackend', 'social_auth.backends.google.GoogleBackend', 'social_auth.backends.yahoo.YahooBackend', - 'social_auth.backends.linkedin.LinkedinBackend', + 'social_auth.backends.contrib.linkedin.LinkedinBackend', 'social_auth.backends.contrib.LiveJournalBackend', 'social_auth.backends.contrib.orkut.OrkutBackend', 'social_auth.backends.OpenIDBackend', @@ -450,6 +465,9 @@ Attributions to whom deserves: - Twitter and OAuth improvements +- Quard_ (Vadym Zakovinko) + + - LinkedIn support ---------- @@ -499,6 +517,7 @@ Base work is copyrighted by: .. _Linkedin OAuth: https://www.linkedin.com/secure/developer .. _Orkut OAuth: http://code.google.com/apis/orkut/docs/rest/developers_guide_protocol.html#Authenticating .. _myOpenID: https://www.myopenid.com/ +.. _LiveJournal OpenID: http://www.livejournal.com/support/faqbrowse.bml?faqid=283 .. _pypi: http://pypi.python.org/pypi/django-social-auth/ .. _github: https://github.com/omab/django-social-auth .. _issues in github: https://github.com/omab/django-social-auth/issues @@ -507,4 +526,4 @@ Base work is copyrighted by: .. _jezdez: https://github.com/jezdez .. _alfredo: https://github.com/alfredo .. _mattucf: https://github.com/mattucf -.. _LiveJournal OpenID: http://www.livejournal.com/support/faqbrowse.bml?faqid=283 +.. _Quard: https://github.com/Quard diff --git a/example/app/views.py b/example/app/views.py index a17a0cf..c810726 100644 --- a/example/app/views.py +++ b/example/app/views.py @@ -21,6 +21,7 @@ def done(request): """Login complete view, displays user data""" names = request.user.social_auth.values_list('provider', flat=True) ctx = dict((name.lower().replace('-', '_'), True) for name in names) + print ctx ctx['version'] = version return render_to_response('done.html', ctx, RequestContext(request)) diff --git a/example/settings.py b/example/settings.py index 8e63d87..a0474cc 100644 --- a/example/settings.py +++ b/example/settings.py @@ -67,7 +67,7 @@ AUTHENTICATION_BACKENDS = ( 'social_auth.backends.google.GoogleOAuthBackend', 'social_auth.backends.google.GoogleBackend', 'social_auth.backends.yahoo.YahooBackend', - 'social_auth.backends.linkedin.LinkedinBackend', + 'social_auth.backends.contrib.linkedin.LinkedinBackend', 'social_auth.backends.OpenIDBackend', 'social_auth.backends.contrib.livejournal.LiveJournalBackend', 'django.contrib.auth.backends.ModelBackend', diff --git a/example/templates/done.html b/example/templates/done.html index 4730545..fa2bcdb 100644 --- a/example/templates/done.html +++ b/example/templates/done.html @@ -25,6 +25,10 @@ Facebook {% if facebook %}(disconnect){% endif %} +
  • + LinkedIn + {% if linkedin %}(disconnect){% endif %} +
  • Orkut {% if orkut %}(disconnect){% endif %} diff --git a/social_auth/backends/contrib/linkedin.py b/social_auth/backends/contrib/linkedin.py index 931b8f8..937f75c 100644 --- a/social_auth/backends/contrib/linkedin.py +++ b/social_auth/backends/contrib/linkedin.py @@ -4,16 +4,18 @@ Linkedin OAuth support No extra configurations are needed to make this work. """ import urlparse -import xml from xml.etree import ElementTree -from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME +from social_auth.backends import ConsumerBasedOAuth, OAuthBackend LINKEDIN_SERVER = 'linkedin.com' -LINKEDIN_REQUEST_TOKEN_URL = 'https://api.%s/uas/oauth/requestToken' % LINKEDIN_SERVER -LINKEDIN_ACCESS_TOKEN_URL = 'https://api.%s/uas/oauth/accessToken' % LINKEDIN_SERVER -LINKEDIN_AUTHORIZATION_URL = 'https://www.%s/uas/oauth/authenticate' % LINKEDIN_SERVER +LINKEDIN_REQUEST_TOKEN_URL = 'https://api.%s/uas/oauth/requestToken' % \ + LINKEDIN_SERVER +LINKEDIN_ACCESS_TOKEN_URL = 'https://api.%s/uas/oauth/accessToken' % \ + LINKEDIN_SERVER +LINKEDIN_AUTHORIZATION_URL = 'https://www.%s/uas/oauth/authenticate' % \ + LINKEDIN_SERVER LINKEDIN_CHECK_AUTH = 'https://api.%s/v1/people/~' % LINKEDIN_SERVER @@ -60,13 +62,8 @@ class LinkedinAuth(ConsumerBasedOAuth): return True -# Backend definition -BACKENDS = { - 'linkedin': LinkedinAuth, -} - - def _xml_to_dict(xml): + """Convert xml structure to dict""" data = {} for child in xml.getchildren(): if child.getchildren(): @@ -75,3 +72,9 @@ def _xml_to_dict(xml): data[child.tag] = child.text return data + + +# Backend definition +BACKENDS = { + 'linkedin': LinkedinAuth, +}