Skip to content

Commit 37a631b

Browse files
committed
Rename requested fields to retain (some) compatibility with v1
1 parent 08005a3 commit 37a631b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/omniauth/strategies/linkedin.rb

Lines changed: 17 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_liteprofile r_emailaddress'
18-
option :fields, ['id', 'firstName', 'lastName', 'profilePicture(displayImage~:playableStreams)']
18+
option :fields, ['id', 'first-name', 'last-name', 'picture-url']
1919

2020
# These are called after authentication has succeeded. If
2121
# possible, you should try to set the UID without making
@@ -60,6 +60,21 @@ def raw_info
6060

6161
private
6262

63+
def fields_mapping
64+
{
65+
'id' => 'id',
66+
'first-name' => 'firstName',
67+
'last-name' => 'lastName',
68+
'picture-url' => 'profilePicture(displayImage~:playableStreams)'
69+
}
70+
end
71+
72+
def fields
73+
options.fields.each.with_object([]) do |field, result|
74+
result << fields_mapping[field]
75+
end
76+
end
77+
6378
def localized_field field_name
6479
return unless localized_field_available? field_name
6580

@@ -92,7 +107,7 @@ def picture_references
92107
end
93108

94109
def profile_endpoint
95-
"/v2/me?projection=(#{ options.fields.join(',') })"
110+
"/v2/me?projection=(#{ fields.join(',') })"
96111
end
97112
end
98113
end

0 commit comments

Comments
 (0)