]> git.parisson.com Git - django-social-auth.git/commitdiff
LinkedIn Support from Quard. Closes gh-34
authorMatías Aguirre <matiasaguirre@gmail.com>
Sun, 6 Mar 2011 14:21:04 +0000 (12:21 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Sun, 6 Mar 2011 14:22:08 +0000 (12:22 -0200)
README.rst
example/app/views.py
example/settings.py
example/templates/done.html
social_auth/backends/contrib/linkedin.py

index 32f5b8e45bbce9caede200eae171b3527396b0e1..900e45eadf1e693aeeb91ab066137a105ecd63c8 100644 (file)
@@ -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
index a17a0cf54b7913b194acb9793bcf77081d8b0131..c810726fa2eb09f0f741371b4b5d2ea10e826768 100644 (file)
@@ -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))
 
index 8e63d8740b578c5cdb474d5fd9580d2a96b5107f..a0474cc9e1e76683c899172b56de3524a7b72a09 100644 (file)
@@ -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',
index 47305453b91d0ab87c6a6218aa1734d732999de9..fa2bcdb6a86ffe4759adf1131751baa2da6a013b 100644 (file)
       <a rel="nofollow" href="{% url associate_begin "facebook" %}">Facebook</a>
       {% if facebook %}<span class="disconnect">(<a href="{% url disconnect "facebook" %}">disconnect</a>)</span>{% endif %}
     </li>
+    <li>
+      <a rel="nofollow" href="{% url associate_begin "linkedin" %}">LinkedIn</a>
+      {% if linkedin %}<span class="disconnect">(<a href="{% url disconnect "linkedin" %}">disconnect</a>)</span>{% endif %}
+    </li>
     <li>
       <a rel="nofollow" href="{% url associate_begin "orkut" %}">Orkut</a>
       {% if orkut %}<span class="disconnect">(<a href="{% url disconnect "orkut" %}">disconnect</a>)</span>{% endif %}
index 931b8f8e27493c77f206b610c1a845f1e5390ed8..937f75c39631e0b7aaa1d2f11789968072ee0115 100644 (file)
@@ -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,
+}