diff --git a/README.md b/README.md index b9789a5..16ebe7f 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :scope => 'r_fu When specifying which permissions you want to users to grant to your application, you will probably want to specify the array of fields that you want returned in the omniauth hash. The list of default fields is as follows: ```ruby -['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url'] +['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-urls::(original)', 'public-profile-url'] ``` Here's an example of a possible configuration where the fields returned from the API are: id, email-address, first-name and last-name. diff --git a/lib/omniauth/strategies/linkedin.rb b/lib/omniauth/strategies/linkedin.rb index bb28cea..e536c23 100755 --- a/lib/omniauth/strategies/linkedin.rb +++ b/lib/omniauth/strategies/linkedin.rb @@ -15,7 +15,7 @@ class LinkedIn < OmniAuth::Strategies::OAuth2 } option :scope, 'r_basicprofile r_emailaddress' - option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url'] + option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-urls::(original)', 'public-profile-url'] # These are called after authentication has succeeded. If # possible, you should try to set the UID without making @@ -33,7 +33,7 @@ class LinkedIn < OmniAuth::Strategies::OAuth2 :last_name => raw_info['lastName'], :location => raw_info['location'], :description => raw_info['headline'], - :image => raw_info['pictureUrl'], + :image => raw_info.fetch('pictureUrls', {}).fetch('values', []).first, :urls => { 'public_profile' => raw_info['publicProfileUrl'] }