omniauth-linkedin-oauth2 0.1.5 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c1ea4a52194f6a78191049881d96bf753e48037
4
- data.tar.gz: fd5aeb28503ef56bba18876b5784b755585cbbb6
3
+ metadata.gz: ab29207dc1df42074dfd2f67013de227d2c6975d
4
+ data.tar.gz: 2228ae416dc859c6de0e475e5af90f3becba4160
5
5
  SHA512:
6
- metadata.gz: c703d367e0f9922e72d5bc2f73e10c8f926d4038a2abb77897f4a3e070445076d1557ddd04eeb8724207e981838c5ddd72792a95062a5ce0bc1ba3c4e1394245
7
- data.tar.gz: 76cccbed6fac06e22be7e027056a3099c3b4870cc2c6b6cbaa7fe4895bd835bf19cf9b14a6888b057bb160cc74c56fcd149714f2f0ead1d294496a85434f1cb9
6
+ metadata.gz: 61991a55b3fd1294691f8be37afa2abca4812fb6f48b381bca66fa3e8655862cb6f0fe7e866a523f0d59467a610c5c8185252d2c37e8e2e997da56f59a38f0b6
7
+ data.tar.gz: 1cdae475837c9c89d7d41769f73799754c84b92f80686502e87b30919c9d3f380c27836804d23977d709c14c11514afcce8554a7a9235427644f07b2413830a4
data/README.md CHANGED
@@ -71,6 +71,10 @@ provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :fields => ['id
71
71
 
72
72
  To see a complete list of available fields, consult the LinkedIn documentation at: https://developer.linkedin.com/documents/profile-fields
73
73
 
74
+ ## Other Options
75
+
76
+ * `secure_image_url` - Set to `true` to use https for the profile picture url. Default is `false`.
77
+
74
78
  ## Contributing
75
79
 
76
80
  1. Fork it
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module LinkedInOAuth2
3
- VERSION = "0.1.5"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -10,8 +10,8 @@ module OmniAuth
10
10
  # initializing your consumer from the OAuth gem.
11
11
  option :client_options, {
12
12
  :site => 'https://api.linkedin.com',
13
- :authorize_url => 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code',
14
- :token_url => 'https://www.linkedin.com/uas/oauth2/accessToken'
13
+ :authorize_url => 'https://www.linkedin.com/oauth/v2/authorization?response_type=code',
14
+ :token_url => 'https://www.linkedin.com/oauth/v2/accessToken'
15
15
  }
16
16
 
17
17
  option :scope, 'r_basicprofile r_emailaddress'
@@ -44,6 +44,10 @@ module OmniAuth
44
44
  { 'raw_info' => raw_info }
45
45
  end
46
46
 
47
+ def callback_url
48
+ full_host + script_name + callback_path
49
+ end
50
+
47
51
  alias :oauth2_access_token :access_token
48
52
 
49
53
  def access_token
@@ -56,11 +60,17 @@ module OmniAuth
56
60
  end
57
61
 
58
62
  def raw_info
59
- @raw_info ||= access_token.get("/v1/people/~:(#{options.fields.join(',')})?format=json").parsed
63
+ @raw_info ||= access_token.get("/v1/people/~:(#{option_fields.join(',')})?format=json").parsed
60
64
  end
61
65
 
62
66
  private
63
67
 
68
+ def option_fields
69
+ fields = options.fields
70
+ fields.map! { |f| f == "picture-url" ? "picture-url;secure=true" : f } if !!options[:secure_image_url]
71
+ fields
72
+ end
73
+
64
74
  def user_name
65
75
  name = "#{raw_info['firstName']} #{raw_info['lastName']}".strip
66
76
  name.empty? ? nil : name
@@ -24,6 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency 'bundler', '~> 1.3'
25
25
  gem.add_development_dependency 'rake'
26
26
 
27
- gem.add_development_dependency 'rspec', '~> 2.13.0'
27
+ gem.add_development_dependency 'rspec', '~> 2.14.1'
28
28
  gem.add_development_dependency 'simplecov'
29
29
  end
@@ -5,82 +5,86 @@ describe OmniAuth::Strategies::LinkedIn do
5
5
  subject { OmniAuth::Strategies::LinkedIn.new(nil) }
6
6
 
7
7
  it 'should add a camelization for itself' do
8
- OmniAuth::Utils.camelize('linkedin').should == 'LinkedIn'
8
+ expect(OmniAuth::Utils.camelize('linkedin')).to eq('LinkedIn')
9
9
  end
10
10
 
11
11
  describe '#client' do
12
12
  it 'has correct LinkedIn site' do
13
- subject.client.site.should eq('https://api.linkedin.com')
13
+ expect(subject.client.site).to eq('https://api.linkedin.com')
14
14
  end
15
15
 
16
16
  it 'has correct authorize url' do
17
- subject.client.options[:authorize_url].should eq('https://www.linkedin.com/uas/oauth2/authorization?response_type=code')
17
+ expect(subject.client.options[:authorize_url]).to eq('https://www.linkedin.com/oauth/v2/authorization?response_type=code')
18
18
  end
19
19
 
20
20
  it 'has correct token url' do
21
- subject.client.options[:token_url].should eq('https://www.linkedin.com/uas/oauth2/accessToken')
21
+ expect(subject.client.options[:token_url]).to eq('https://www.linkedin.com/oauth/v2/accessToken')
22
22
  end
23
23
  end
24
24
 
25
25
  describe '#callback_path' do
26
26
  it 'has the correct callback path' do
27
- subject.callback_path.should eq('/auth/linkedin/callback')
27
+ expect(subject.callback_path).to eq('/auth/linkedin/callback')
28
28
  end
29
29
  end
30
30
 
31
31
  describe '#uid' do
32
32
  before :each do
33
- subject.stub(:raw_info) { { 'id' => 'uid' } }
33
+ allow(subject).to receive(:raw_info) { { 'id' => 'uid' } }
34
34
  end
35
35
 
36
36
  it 'returns the id from raw_info' do
37
- subject.uid.should eq('uid')
37
+ expect(subject.uid).to eq('uid')
38
38
  end
39
39
  end
40
40
 
41
41
  describe '#info' do
42
42
  before :each do
43
- subject.stub(:raw_info) { {} }
43
+ allow(subject).to receive(:raw_info) { {} }
44
44
  end
45
45
 
46
46
  context 'and therefore has all the necessary fields' do
47
- it { subject.info.should have_key :name }
48
- it { subject.info.should have_key :email }
49
- it { subject.info.should have_key :nickname }
50
- it { subject.info.should have_key :first_name }
51
- it { subject.info.should have_key :last_name }
52
- it { subject.info.should have_key :location }
53
- it { subject.info.should have_key :description }
54
- it { subject.info.should have_key :image }
55
- it { subject.info.should have_key :urls }
47
+ it { expect(subject.info).to have_key :name }
48
+ it { expect(subject.info).to have_key :email }
49
+ it { expect(subject.info).to have_key :nickname }
50
+ it { expect(subject.info).to have_key :first_name }
51
+ it { expect(subject.info).to have_key :last_name }
52
+ it { expect(subject.info).to have_key :location }
53
+ it { expect(subject.info).to have_key :description }
54
+ it { expect(subject.info).to have_key :image }
55
+ it { expect(subject.info).to have_key :urls }
56
56
  end
57
57
  end
58
58
 
59
59
  describe '#extra' do
60
60
  before :each do
61
- subject.stub(:raw_info) { { :foo => 'bar' } }
61
+ allow(subject).to receive(:raw_info) { { :foo => 'bar' } }
62
62
  end
63
63
 
64
- it { subject.extra['raw_info'].should eq({ :foo => 'bar' }) }
64
+ it { expect(subject.extra['raw_info']).to eq({ :foo => 'bar' }) }
65
65
  end
66
66
 
67
67
  describe '#access_token' do
68
68
  before :each do
69
- subject.stub(:oauth2_access_token) { double('oauth2 access token', :expires_in => 3600, :expires_at => 946688400).as_null_object }
69
+ allow(subject).to receive(:oauth2_access_token) { double('oauth2 access token', :expires_in => 3600, :expires_at => 946688400).as_null_object }
70
70
  end
71
71
 
72
- it { subject.access_token.expires_in.should eq(3600) }
73
- it { subject.access_token.expires_at.should eq(946688400) }
72
+ it { expect(subject.access_token.expires_in).to eq(3600) }
73
+ it { expect(subject.access_token.expires_at).to eq(946688400) }
74
74
  end
75
75
 
76
76
  describe '#raw_info' do
77
77
  before :each do
78
+ access_token = double('access token')
78
79
  response = double('response', :parsed => { :foo => 'bar' })
79
- subject.stub(:access_token) { double('access token', :get => response) }
80
+ expect(access_token).to receive(:get).with("/v1/people/~:(baz,qux)?format=json").and_return(response)
81
+
82
+ allow(subject).to receive(:option_fields) { ['baz', 'qux'] }
83
+ allow(subject).to receive(:access_token) { access_token }
80
84
  end
81
85
 
82
86
  it 'returns parsed response from access token' do
83
- subject.raw_info.should eq({ :foo => 'bar' })
87
+ expect(subject.raw_info).to eq({ :foo => 'bar' })
84
88
  end
85
89
  end
86
90
 
@@ -91,8 +95,27 @@ describe OmniAuth::Strategies::LinkedIn do
91
95
  end
92
96
 
93
97
  it 'sets default scope' do
94
- subject.authorize_params['scope'].should eq('r_basicprofile r_emailaddress')
98
+ expect(subject.authorize_params['scope']).to eq('r_basicprofile r_emailaddress')
95
99
  end
96
100
  end
97
101
  end
102
+
103
+ describe '#option_fields' do
104
+ it 'returns options fields' do
105
+ subject.stub(:options => double('options', :fields => ['foo', 'bar']).as_null_object)
106
+ expect(subject.send(:option_fields)).to eq(['foo', 'bar'])
107
+ end
108
+
109
+ it 'http avatar image by default' do
110
+ subject.stub(:options => double('options', :fields => ['picture-url']))
111
+ allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(false)
112
+ expect(subject.send(:option_fields)).to eq(['picture-url'])
113
+ end
114
+
115
+ it 'https avatar image if secure_image_url truthy' do
116
+ subject.stub(:options => double('options', :fields => ['picture-url']))
117
+ allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(true)
118
+ expect(subject.send(:option_fields)).to eq(['picture-url;secure=true'])
119
+ end
120
+ end
98
121
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-linkedin-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Décio Ferreira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-15 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.13.0
75
+ version: 2.14.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.13.0
82
+ version: 2.14.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: A LinkedIn OAuth2 strategy for OmniAuth.
@@ -101,9 +101,9 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
105
- - .rspec
106
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
107
  - Gemfile
108
108
  - LICENSE.txt
109
109
  - README.md
@@ -126,17 +126,17 @@ require_paths:
126
126
  - lib
127
127
  required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - '>='
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.1.9
139
+ rubygems_version: 2.6.11
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: A LinkedIn OAuth2 strategy for OmniAuth.