Skip to content

Commit 02cc9f4

Browse files
committed
Support for picture-urls::(original) and profile picture
- 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
1 parent e421860 commit 02cc9f4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :scope => 'r_fu
6060
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:
6161

6262
```ruby
63-
['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url']
63+
['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-urls::(original)', 'public-profile-url']
6464
```
6565

6666
Here's an example of a possible configuration where the fields returned from the API are: id, email-address, first-name and last-name.

lib/omniauth/strategies/linkedin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LinkedIn < OmniAuth::Strategies::OAuth2
1515
}
1616

1717
option :scope, 'r_basicprofile r_emailaddress'
18-
option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url']
18+
option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-urls::(original)', 'public-profile-url']
1919

2020
# These are called after authentication has succeeded. If
2121
# possible, you should try to set the UID without making
@@ -33,7 +33,7 @@ class LinkedIn < OmniAuth::Strategies::OAuth2
3333
:last_name => raw_info['lastName'],
3434
:location => raw_info['location'],
3535
:description => raw_info['headline'],
36-
:image => raw_info['pictureUrl'],
36+
:image => raw_info.fetch('pictureUrls', {}).fetch('values', []).first,
3737
:urls => {
3838
'public_profile' => raw_info['publicProfileUrl']
3939
}

0 commit comments

Comments
 (0)