Skip to content

Commit

Permalink
Support for picture-urls::(original) and profile picture
Browse files Browse the repository at this point in the history
- fetch picture-urls::(original) field instead of picture-url
- use the first image of pictureUrls array as profile image
- update README to reflect these changes
  • Loading branch information
EppO committed Nov 17, 2015
1 parent e421860 commit 02cc9f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib/omniauth/strategies/linkedin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']
}
Expand Down

0 comments on commit 02cc9f4

Please sign in to comment.