bbangert / velruse

Simplifying third-party authentication for web applications.
http://packages.python.org/velruse/index.html
MIT License
252 stars 86 forks source link

Get email from linkedin and make routes consistent with other providers #119

Closed marcolarosa closed 11 years ago

marcolarosa commented 11 years ago

Hi,

I was wondering if you could configure the email to be returned from linkedin and also make the route consistent.

Following is a diff of the requested changes.

Thanks!

diff --git a/providers/linkedin.py b/providers/linkedin.py
index 17c69d5..ce9915b 100644
--- a/providers/linkedin.py
+++ b/providers/linkedin.py
@@ -44,8 +44,8 @@ def add_linkedin_login_from_settings(config, prefix='velruse.linkedin.'):
 def add_linkedin_login(config,
                        consumer_key,
                        consumer_secret,
-                       login_path='/linkedin/login',
-                       callback_path='/linkedin/login/callback',
+                       login_path='/login/linkedin',
+                       callback_path='/login/linkedin/callback',
                        name='linkedin'):
     """
     Add a Last.fm login provider to the application.
@@ -129,7 +129,7 @@ class LinkedInProvider(object):
                             secret=cred['oauthAccessTokenSecret'])
         client = oauth.Client(consumer, token)
         profile_url = 'http://api.linkedin.com/v1/people/~'
-        profile_url += ':(first-name,last-name,id,date-of-birth,picture-url)'
+        profile_url += ':(first-name,last-name,id,date-of-birth,picture-url,email-address)'
         profile_url += '?format=json'
         resp, content = client.request(profile_url)

@@ -139,8 +139,8 @@ class LinkedInProvider(object):

         # Setup the normalized contact info
         profile = {}
         profile['displayName'] = data['firstName'] + data['lastName']
+        profile['verifiedEmail'] = data['emailAddress']
         profile['name'] = {
             'givenName': data['firstName'],
             'familyName': data['lastName'],
keul commented 11 years ago

@MLR-au We are working on the same issue for linkedin (see our branch at https://github.com/RedTurtle/velruse) but we don't use verifiedEmail (because it's not verified) but the Portable Contacts standard emails.

marcolarosa commented 11 years ago

Sure - I don't have an issue with that. I was just following what was in the google_oauth2 provider. I must admit, I didn't look up the linkedin api docs to see if the email is verified or not.

From my point of view, if we could depend on 'emails' being consistent across all providers that would be nice.

mmerickel commented 11 years ago

I will look into this. I've been trying to standardize the "emails" list in the profile as I go through things this last week. I don't have a linkedin account atm, but if someone wants to add a test for linked in "tests/selenium/tests.py" I'd be happy to merge it. Without the test you'll have to wait for me to take care of things. :-)

keul commented 11 years ago

@mmerickel I can try to look at this also.

keul commented 11 years ago

See https://github.com/bbangert/velruse/pull/121

mmerickel commented 11 years ago

121 and 93fecec should take care of these issues.