omniauth-linkedin 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.2@omniauth-linkedin
1
+ rvm --create 1.9.3@omniauth-linkedin
data/Gemfile CHANGED
@@ -3,8 +3,6 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in omniauth-linkedin.gemspec
4
4
  gemspec
5
5
 
6
- gem 'omniauth-oauth', :git => 'https://github.com/intridea/omniauth-oauth.git'
7
-
8
6
  group :development, :test do
9
7
  gem 'guard'
10
8
  gem 'guard-rspec'
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # OmniAuth LinkedIn
2
2
 
3
- **Note:** This gem is designed to work with the unreleased OmniAuth 1.0 library. It will not be officially released on RubyGems.org until OmniAuth 1.0 is released.
3
+ This gem contains the LinkedIn strategy for OmniAuth 1.0 .
4
4
 
5
- This gem contains the LinkedIn strategy for OmniAuth.
6
-
7
- LinkedIn uses the OAuth 1.0a flow, you can read about it here: https://developer.linkedin.com/documents/authentication
5
+ LinkedIn uses the OAuth 1.0a flow, you can read about it here: https://developer.linkedin.com/documents/authentication
8
6
 
9
7
  ## How To Use It
10
8
 
@@ -13,21 +11,46 @@ Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails
13
11
  gem 'omniauth'
14
12
  gem 'omniauth-linkedin'
15
13
 
16
- Of course if one or both of these are unreleased, you may have to pull them in directly from github e.g.:
17
-
18
- gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
19
- gem 'omniauth-linkedin', :git => 'https://github.com/skorks/omniauth-linkedin.git'
20
-
21
14
  Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
22
15
 
23
16
  Rails.application.config.middleware.use OmniAuth::Builder do
24
- provider :linkedin, "consumer_key", "consumer_secret"
17
+ provider :linkedin, "consumer_key", "consumer_secret"
25
18
  end
26
19
 
27
- You will obviously have to put in your key and secret, which you get when you register your app with LinkedIn (they call them API Key and Secret Key).
20
+ You will obviously have to put in your key and secret, which you get when you register your app with LinkedIn (they call them API Key and Secret Key).
28
21
 
29
22
  Now just follow the README at: https://github.com/intridea/omniauth
30
23
 
24
+ ## Additional permissions
25
+
26
+ LinkedIn recently (August 2012) provided the ability to request different permissions by specifying a scope. You can find more information on the different permissions at https://developer.linkedin.com/documents/authentication
27
+
28
+ By default, omniauth-linkedin requests the following permissions:
29
+
30
+ r_basicprofile+r_emailaddress
31
+
32
+ This allows us to obtain enough information from LinkedIn to satisfy the requirements for the basic auth hash schema.
33
+
34
+ To change the scope, simply change your initializer to something like this:
35
+
36
+ Rails.application.config.middleware.use OmniAuth::Builder do
37
+ provider :linkedin, "consumer_key", "consumer_secret", :scope => 'r_fullprofile+r_emailaddress+r_network'
38
+ end
39
+
40
+ One thing to note is the fact that when you ask for extra permissions, you will probably want to specify the array of fields that you want returned in the omniauth hash. If you don't then only the default fields (see below) will be returned which would defeat the purpose of asking for the extra permissions. So do the following:
41
+
42
+ Rails.application.config.middleware.use OmniAuth::Builder do
43
+ provider :linkedin, "consumer_key", "consumer_secret", :scope => 'r_fullprofile+r_emailaddress+r_network', :fields => ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location", "connections"]
44
+ end
45
+
46
+ We have to repeat the list of default fields in order to get the extra 'connections' field.
47
+
48
+ The list of default fields is as follows:
49
+
50
+ ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location"]
51
+
52
+ To see a complete list of available fields, consult the LinkedIn documentation at https://developer.linkedin.com/documents/profile-fields
53
+
31
54
  ## Using It With The LinkedIn Gem
32
55
 
33
56
  You may find that you want to use OmniAuth for authentication, but you want to use an API wrapper such as this one https://github.com/pengwynn/linkedin to actually make your api calls. But the LinkedIn gem provides it's own way to authenticate with LinkedIn via OAuth. In this case you can do the following.
data/example/Gemfile CHANGED
@@ -3,4 +3,3 @@ source :rubygems
3
3
  gem 'sinatra'
4
4
  gem 'multi_json'
5
5
  gem 'omniauth-linkedin', :path => '../'
6
- #gem 'omniauth-linkedin'
data/example/config.ru CHANGED
@@ -11,7 +11,7 @@ class App < Sinatra::Base
11
11
  content_type 'application/json'
12
12
  MultiJson.encode(request.env)
13
13
  end
14
-
14
+
15
15
  get '/auth/failure' do
16
16
  content_type 'application/json'
17
17
  MultiJson.encode(request.env)
@@ -21,7 +21,10 @@ end
21
21
  use Rack::Session::Cookie
22
22
 
23
23
  use OmniAuth::Builder do
24
- provider :linkedin, ENV['LINKEDIN_CONSUMER_KEY'], ENV['LINKEDIN_CONSUMER_SECRET']
24
+ #note that the scope is different from the default
25
+ #we also have to repeat the default fields in order to get
26
+ #the extra 'connections' field in there
27
+ provider :linkedin, ENV['LINKEDIN_CONSUMER_KEY'], ENV['LINKEDIN_CONSUMER_SECRET'], :scope => 'r_fullprofile+r_emailaddress+r_network', :fields => ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location", "connections"]
25
28
  end
26
29
 
27
30
  run App.new
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Linkedin
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -12,16 +12,19 @@ module OmniAuth
12
12
  :authorize_url => 'https://www.linkedin.com/uas/oauth/authenticate'
13
13
  }
14
14
 
15
- option :fields, ["id", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url"]
15
+ option :fields, ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location"]
16
+ option :scope, 'r_basicprofile+r_emailaddress'
16
17
 
17
18
  uid{ raw_info['id'] }
18
19
 
19
20
  info do
20
21
  {
22
+ :email => raw_info['emailAddress'],
21
23
  :first_name => raw_info['firstName'],
22
24
  :last_name => raw_info['lastName'],
23
25
  :name => "#{raw_info['firstName']} #{raw_info['lastName']}",
24
26
  :headline => raw_info['headline'],
27
+ :description => raw_info['headline'],
25
28
  :image => raw_info['pictureUrl'],
26
29
  :industry => raw_info['industry'],
27
30
  :urls => {
@@ -37,6 +40,12 @@ module OmniAuth
37
40
  def raw_info
38
41
  @raw_info ||= MultiJson.decode(access_token.get("/v1/people/~:(#{options.fields.join(',')})?format=json").body)
39
42
  end
43
+
44
+ def request_phase
45
+ options.client_options.request_token_path = "#{options.client_options.request_token_path}?scope=#{options.scope}"
46
+
47
+ super
48
+ end
40
49
  end
41
50
  end
42
51
  end
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
19
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
20
20
 
21
- s.add_development_dependency 'rspec', '~> 2.7.0'
21
+ s.add_development_dependency 'rspec', '~> 2.7'
22
22
  s.add_development_dependency 'rake'
23
23
  s.add_development_dependency 'webmock'
24
24
  s.add_development_dependency 'rack-test'
metadata CHANGED
@@ -1,83 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: omniauth-linkedin
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
4
5
  prerelease:
5
- version: 0.0.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Alan Skorkin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-16 00:00:00 +11:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: omniauth-oauth
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: 1.0.0
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
31
33
  none: false
32
- requirements:
34
+ requirements:
33
35
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 2.7.0
36
+ - !ruby/object:Gem::Version
37
+ version: '2.7'
36
38
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: rake
40
39
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
42
49
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
47
54
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: webmock
51
55
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
53
65
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
58
70
  type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rack-test
62
71
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
64
73
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack-test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
69
86
  type: :development
70
- version_requirements: *id005
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
71
94
  description: LinkedIn strategy for OmniAuth.
72
- email:
95
+ email:
73
96
  - alan@skorks.com
74
97
  executables: []
75
-
76
98
  extensions: []
77
-
78
99
  extra_rdoc_files: []
79
-
80
- files:
100
+ files:
81
101
  - .gitignore
82
102
  - .rspec
83
103
  - .rvmrc
@@ -93,34 +113,30 @@ files:
93
113
  - omniauth-linkedin.gemspec
94
114
  - spec/omniauth/strategies/linkedin_spec.rb
95
115
  - spec/spec_helper.rb
96
- has_rdoc: true
97
116
  homepage: https://github.com/skorks/omniauth-linkedin
98
117
  licenses: []
99
-
100
118
  post_install_message:
101
119
  rdoc_options: []
102
-
103
- require_paths:
120
+ require_paths:
104
121
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
122
+ required_ruby_version: !ruby/object:Gem::Requirement
106
123
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: "0"
111
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
129
  none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
117
134
  requirements: []
118
-
119
135
  rubyforge_project:
120
- rubygems_version: 1.6.2
136
+ rubygems_version: 1.8.21
121
137
  signing_key:
122
138
  specification_version: 3
123
139
  summary: LinkedIn strategy for OmniAuth.
124
- test_files:
140
+ test_files:
125
141
  - spec/omniauth/strategies/linkedin_spec.rb
126
142
  - spec/spec_helper.rb