Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :fields => ['id

To see a complete list of available fields, consult the LinkedIn documentation at: https://developer.linkedin.com/documents/profile-fields

## Other Options

* `secure_image_url` - Set to `true` to use https for the profile picture url. Default is `false`.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
8 changes: 1 addition & 7 deletions lib/omniauth/strategies/linkedin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@ def access_token
end

def raw_info
@raw_info ||= access_token.get("/v1/people/~:(#{option_fields.join(',')})?format=json").parsed
@raw_info ||= access_token.get("/v1/people/~:(#{fields.join(',')})?format=json").parsed
end

private

def option_fields
fields = options.fields
fields.map! { |f| f == "picture-url" ? "picture-url;secure=true" : f } if !!options[:secure_image_url]
fields
end

def user_name
name = "#{raw_info['firstName']} #{raw_info['lastName']}".strip
name.empty? ? nil : name
Expand Down
20 changes: 0 additions & 20 deletions spec/omniauth/strategies/linkedin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
response = double('response', :parsed => { :foo => 'bar' })
expect(access_token).to receive(:get).with("/v1/people/~:(baz,qux)?format=json").and_return(response)

allow(subject).to receive(:option_fields) { ['baz', 'qux'] }
allow(subject).to receive(:access_token) { access_token }
end

Expand All @@ -99,23 +98,4 @@
end
end
end

describe '#option_fields' do
it 'returns options fields' do
subject.stub(:options => double('options', :fields => ['foo', 'bar']).as_null_object)
expect(subject.send(:option_fields)).to eq(['foo', 'bar'])
end

it 'http avatar image by default' do
subject.stub(:options => double('options', :fields => ['picture-url']))
allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(false)
expect(subject.send(:option_fields)).to eq(['picture-url'])
end

it 'https avatar image if secure_image_url truthy' do
subject.stub(:options => double('options', :fields => ['picture-url']))
allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(true)
expect(subject.send(:option_fields)).to eq(['picture-url;secure=true'])
end
end
end