omniauth-paypal 1.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWFiOTYxMmIxMmFlMDU5ZDllNDc3YWU3OWEzZjYwNmFjZTlkNDVkMQ==
5
+ data.tar.gz: !binary |-
6
+ M2Y3ZmFmZDU5MThlYWUzOWVlMWEwNmRhNzg0Y2JkZTEwNzU2MGQ2NA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGYzY2UyYWJhZDM1MDkxOGI2ZTgxYzIwZGZkNWZjODM2MzRlZTg3NThjODQ4
10
+ MzNmMjE0ODVkMGMxYmM0ZmY5N2IzNjFjMjljM2Y4ODhiZDZiOTg3OWEzNzRm
11
+ ZTY5OTJjMzU2ZjQyMTY2ZTA0NGIyYjkwNjMwZTgzOTRiM2M4ODE=
12
+ data.tar.gz: !binary |-
13
+ YTA3OGZiNDA1YTU3ODg2ZjRhNTNkY2QwNmUxY2VkMzJlMDE0YjM3MzhlNGRh
14
+ NDllZDJkZjIzNzQwNGRlM2JhYTU4ODQxZWViMmVmMDc4ZDMwYTY3NTc1MGQ4
15
+ ODQwMGJkMWFiNjQ5ZjI1MmQwNTliMTI5NGI5ZTRmMTNmMTViZGE=
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: git://github.com/intridea/omniauth-oauth2.git
3
- revision: d6409bb14337675e22c50f3c76b5d7f672a631a3
3
+ revision: 8a7a97ecbdb71c04b96bfa47dbc465d5d931f694
4
4
  specs:
5
5
  omniauth-oauth2 (1.1.1)
6
6
  oauth2 (~> 0.9.0)
@@ -9,43 +9,43 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- omniauth-paypal (1.0)
12
+ omniauth-paypal (1.2)
13
13
  omniauth-oauth2 (~> 1.1.0)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- diff-lcs (1.1.3)
19
- faraday (0.8.6)
20
- multipart-post (~> 1.1)
21
- hashie (1.2.0)
18
+ diff-lcs (1.2.4)
19
+ faraday (0.8.8)
20
+ multipart-post (~> 1.2.0)
21
+ hashie (2.0.5)
22
22
  httpauth (0.2.0)
23
- json (1.6.6)
24
- jwt (0.1.5)
25
- multi_json (>= 1.0)
26
- multi_json (1.6.1)
27
- multi_xml (0.5.3)
23
+ json (1.8.0)
24
+ jwt (0.1.8)
25
+ multi_json (>= 1.5)
26
+ multi_json (1.8.0)
27
+ multi_xml (0.5.5)
28
28
  multipart-post (1.2.0)
29
- oauth2 (0.9.1)
29
+ oauth2 (0.9.2)
30
30
  faraday (~> 0.8)
31
- httpauth (~> 0.1)
31
+ httpauth (~> 0.2)
32
32
  jwt (~> 0.1.4)
33
33
  multi_json (~> 1.0)
34
34
  multi_xml (~> 0.5)
35
35
  rack (~> 1.2)
36
- omniauth (1.1.3)
37
- hashie (~> 1.2)
36
+ omniauth (1.1.4)
37
+ hashie (>= 1.2, < 3)
38
38
  rack
39
39
  rack (1.5.2)
40
- rake (0.9.2.2)
41
- rspec (2.7.0)
42
- rspec-core (~> 2.7.0)
43
- rspec-expectations (~> 2.7.0)
44
- rspec-mocks (~> 2.7.0)
45
- rspec-core (2.7.1)
46
- rspec-expectations (2.7.0)
47
- diff-lcs (~> 1.1.2)
48
- rspec-mocks (2.7.0)
40
+ rake (10.1.0)
41
+ rspec (2.14.1)
42
+ rspec-core (~> 2.14.0)
43
+ rspec-expectations (~> 2.14.0)
44
+ rspec-mocks (~> 2.14.0)
45
+ rspec-core (2.14.5)
46
+ rspec-expectations (2.14.3)
47
+ diff-lcs (>= 1.1.3, < 2.0)
48
+ rspec-mocks (2.14.3)
49
49
 
50
50
  PLATFORMS
51
51
  ruby
@@ -55,4 +55,4 @@ DEPENDENCIES
55
55
  omniauth-oauth2 (~> 1.1.1)!
56
56
  omniauth-paypal!
57
57
  rake
58
- rspec (~> 2.7.0)
58
+ rspec (~> 2.14)
data/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  **Note:** This gem is designed to work with OmniAuth 1.0 library.
4
4
 
5
- This gem contains the PayPal Access using OpenID strategy for OmniAuth.
5
+ This gem contains the Log In With PayPal strategy for OmniAuth.
6
6
 
7
7
  ## Installing
8
8
 
9
9
  Add to your `Gemfile`:
10
10
 
11
11
  ```ruby
12
- gem 'omniauth-paypal', :git => "git://github.com/datariot/omniauth-paypal.git"
12
+ gem "omniauth-paypal"
13
13
  ```
14
14
 
15
15
  Then `bundle install`.
@@ -20,82 +20,104 @@ Here's a quick example, adding the middleware to a Rails app in `config/initiali
20
20
 
21
21
  ```ruby
22
22
  Rails.application.config.middleware.use OmniAuth::Builder do
23
- provider :paypal, ENV['APP_ID'], ENV['APP_TOKEN']
23
+ provider :paypal, ENV['APP_ID'], ENV['APP_TOKEN'], sandbox: true, scope: "openid profile email"
24
24
  end
25
25
  ```
26
26
 
27
- ## info
27
+ ## Attributes and Scopes
28
28
 
29
- PayPal Access information https://www.x.com/developers/x.commerce/products/paypal-access
29
+ Log In With PayPal information can be found on https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/
30
30
 
31
- The maximum info returned currently is:
31
+ The possible attributes to be returned at the moment are:
32
32
 
33
- info['name']
34
- info['email']
35
- info['first_name']
36
- info['last_name]
37
- info['location']
38
- info['phone']
33
+ ```ruby
34
+ info['name']
35
+ info['email']
36
+ info['first_name'] # also available as given_name
37
+ info['last_name'] # also available as family_name
38
+ info['location']
39
+ info['name']
40
+ info['phone']
41
+
42
+ extra['account_creation_date']
43
+ extra['account_type']
44
+ extra['address']['country']
45
+ extra['address']['locality']
46
+ extra['address']['postal_code']
47
+ extra['address']['region']
48
+ extra['address']['street_address']
49
+ extra['language']
50
+ extra['locale']
51
+ extra['verified_account']
52
+ extra['zoneinfo']
53
+ extra['age_range']
54
+ extra['birthday']
55
+ ```
39
56
 
40
- extra['account_type']
41
- extra['user_id']
42
- extra['address']['postal_code']
43
- extra['address']['locality']
44
- extra['address']['country']
45
- extra['address']['street_address']
46
- extra['verified_account']
47
- extra['language']
48
- extra['zoneinfo']
49
- extra['locale']
50
- extra['account_creation_date']
57
+ The actual set of attributes returned depends on the scopes set. The currently available scopes are:
51
58
 
52
- PayPal docs claim that day of birth also may be returned, but I was not able to find this param name, so it's not currently included.
59
+ ```
60
+ openid
61
+ profile
62
+ email
63
+ address
64
+ phone
65
+ https://uri.paypal.com/services/paypalattributes
66
+ https://uri.paypal.com/services/expresscheckout
67
+ ```
53
68
 
54
- Actual set of attributes depends on these possible scopes:
69
+ (those last 2 are scope names, not links)
55
70
 
56
- openid
57
- profile
58
- email
59
- address
60
- phone
61
- https://uri.paypal.com/services/paypalattributes
62
- (the last is scope name, not a link)
71
+ For more details see the PayPal [list of attributes](https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#attributes).
63
72
 
64
- For details see [this section](https://www.x.com/developers/paypal/documentation-tools/quick-start-guides/oauth-openid-connect-integration-paypal##attributes).
73
+ ## Registering for an API key
65
74
 
66
- To register your application for PayPal Access follow these instructions: https://www.x.com/developers/paypal/how-to-guides/how-register-application-paypal-access
75
+ To register your application for Log In With PayPal head over to the [PayPal Developer portal](https://developer.paypal.com/), log in and register for an application. Make sure to match your scope when registering your app to the scope provided when initializing Omniauth.
67
76
 
77
+ [A full tutorial is available](http://cristianobetta.com/blog/2013/09/27/integrating-login-with-paypal-into-rails/) on how to use Omniauth, Login With PayPal, and the PayPal Developer portal.
68
78
 
69
79
  ## Example of result auth hash
70
80
  With all scopes requested.
71
81
 
72
- provider: paypal
73
- uid: bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw
74
- info:
75
- name: John Smith
76
- email: example@example.com
77
- first_name: John
78
- last_name: Smith
79
- location: Moscow
80
- phone: "71234567890"
81
- credentials:
82
- token: <token>
83
- refresh_token: <refresh token>
84
- expires_at: 1355082790
85
- expires: true
86
- extra:
87
- account_type: PERSONAL
88
- user_id: https://www.paypal.com/webapps/auth/identity/user/bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw
89
- address:
90
- postal_code: "123456"
91
- locality: Moscow
92
- country: RU
93
- street_address: Red square, 1
94
- verified_account: "true"
95
- language: en_US
96
- zoneinfo: America/Los_Angeles
97
- locale: en_US
98
- account_creation_date: "2008-04-21"
82
+ ```yaml
83
+ provider: paypal
84
+ uid: bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw
85
+ info:
86
+ name: John Smith
87
+ email: example@example.com
88
+ first_name: John
89
+ last_name: Smith
90
+ given_name: John
91
+ family_name: Smith
92
+ location: Moscow
93
+ name: John Smith
94
+ phone: "71234567890"
95
+ credentials:
96
+ token: <token>
97
+ refresh_token: <refresh token>
98
+ expires_at: 1355082790
99
+ expires: true
100
+ extra:
101
+ account_creation_date: "2008-04-21"
102
+ account_type: PERSONAL
103
+ user_id: https://www.paypal.com/webapps/auth/identity/user/bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw
104
+ address:
105
+ country: US
106
+ locality: San Jose
107
+ postal_code: "95131"
108
+ region: CA
109
+ street_address: 1 Main St
110
+ language: en_US
111
+ locale: en_US
112
+ verified_account: true
113
+ zoneinfo: America/Los_Angeles
114
+ age_range: 31-35
115
+ birthday: "1982-01-01"
116
+ ```
117
+
118
+ ## Contributing
119
+
120
+ Log In With PayPal has been in flux since I started this project and anything that helps keep this gem up to date and tested is greatly apprecitated. Thanks for your help!
99
121
 
100
122
  ## License
101
123
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module PayPal
3
- VERSION = "1.1"
3
+ VERSION = "1.2"
4
4
  end
5
5
  end
@@ -3,14 +3,15 @@ require 'omniauth-oauth2'
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class PayPal < OmniAuth::Strategies::OAuth2
6
- DEFAULT_SCOPE = "profile"
6
+ DEFAULT_SCOPE = "openid profile"
7
7
  DEFAULT_RESPONSE_TYPE = "code"
8
- SANDBOX_SITE = "https://www.sandbox.paypal.com"
8
+ SANDBOX_SITE = "https://api.sandbox.paypal.com"
9
+ SANDBOX_AUTHORIZE_URL = 'https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize'
9
10
 
10
11
  option :client_options, {
11
- :site => 'https://www.paypal.com',
12
- :authorize_url => '/webapps/auth/protocol/openidconnect/v1/authorize',
13
- :token_url => '/webapps/auth/protocol/openidconnect/v1/tokenservice',
12
+ :site => 'https://api.paypal.com',
13
+ :authorize_url => 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize',
14
+ :token_url => '/v1/identity/openidconnect/tokenservice',
14
15
  :setup => true
15
16
  }
16
17
 
@@ -26,6 +27,8 @@ module OmniAuth
26
27
  'email' => raw_info['email'],
27
28
  'first_name' => raw_info['given_name'],
28
29
  'last_name' => raw_info['family_name'],
30
+ 'given_name' => raw_info['given_name'],
31
+ 'family_name' => raw_info['family_name'],
29
32
  'location' => (raw_info['address'] || {})['locality'],
30
33
  'phone' => raw_info['phone_number']
31
34
  })
@@ -36,16 +39,21 @@ module OmniAuth
36
39
  'account_type' => raw_info['account_type'],
37
40
  'user_id' => raw_info['user_id'],
38
41
  'address' => raw_info['address'],
39
- 'verified_account' => raw_info['verified_account'],
42
+ 'verified_account' => (raw_info['verified_account'] == true),
40
43
  'language' => raw_info['language'],
41
44
  'zoneinfo' => raw_info['zoneinfo'],
42
45
  'locale' => raw_info['locale'],
43
- 'account_creation_date' => raw_info['account_creation_date']
46
+ 'account_creation_date' => raw_info['account_creation_date'],
47
+ 'age_range' => raw_info['age_range'],
48
+ 'birthday' => raw_info['birthday']
44
49
  })
45
50
  end
46
51
 
47
52
  def setup_phase
48
- options.client_options[:site] = SANDBOX_SITE if options.sandbox
53
+ if options.sandbox
54
+ options.client_options[:site] = SANDBOX_SITE
55
+ options.client_options[:authorize_url] = SANDBOX_AUTHORIZE_URL
56
+ end
49
57
  end
50
58
 
51
59
  def raw_info
@@ -64,7 +72,7 @@ module OmniAuth
64
72
  access_token.options[:mode] = :query
65
73
  access_token.options[:param_name] = :access_token
66
74
  access_token.options[:grant_type] = :authorization_code
67
- access_token.get('/webapps/auth/protocol/openidconnect/v1/userinfo', { :params => { :schema => 'openid'}}).parsed || {}
75
+ access_token.get('/v1/identity/openidconnect/userinfo', { :params => { :schema => 'openid'}}).parsed || {}
68
76
  end
69
77
 
70
78
  def prune!(hash)
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
20
20
 
21
- s.add_development_dependency 'rspec', '~> 2.7.0'
21
+ s.add_development_dependency 'rspec', '~> 2.14'
22
22
  s.add_development_dependency 'rake'
23
23
  end
@@ -10,21 +10,27 @@ describe OmniAuth::Strategies::PayPal do
10
10
 
11
11
  describe '#client' do
12
12
  it 'has correct PayPal site' do
13
- subject.client.site.should eq('https://www.paypal.com')
13
+ subject.client.site.should eq('https://api.paypal.com')
14
14
  end
15
15
 
16
16
  it 'has correct PayPal sandbox site' do
17
17
  @options = { :sandbox => true }
18
18
  subject.setup_phase
19
- subject.client.site.should eq('https://www.sandbox.paypal.com')
19
+ subject.client.site.should eq('https://api.sandbox.paypal.com')
20
20
  end
21
21
 
22
22
  it 'has correct authorize url' do
23
- subject.client.options[:authorize_url].should eq('/webapps/auth/protocol/openidconnect/v1/authorize')
23
+ subject.client.options[:authorize_url].should eq('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
24
+ end
25
+
26
+ it 'has correct sandbox authorize url' do
27
+ @options = { :sandbox => true }
28
+ subject.setup_phase
29
+ subject.client.options[:authorize_url].should eq('https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
24
30
  end
25
31
 
26
32
  it 'has correct token url' do
27
- subject.client.options[:token_url].should eq('/webapps/auth/protocol/openidconnect/v1/tokenservice')
33
+ subject.client.options[:token_url].should eq('/v1/identity/openidconnect/tokenservice')
28
34
  end
29
35
  end
30
36
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-paypal
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
5
- prerelease:
4
+ version: '1.2'
6
5
  platform: ruby
7
6
  authors:
8
7
  - David W. Allen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-17 00:00:00.000000000 Z
11
+ date: 2013-10-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth-oauth2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 2.7.0
33
+ version: '2.14'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 2.7.0
40
+ version: '2.14'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -66,6 +59,7 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
62
+ - .gitignore
69
63
  - Gemfile
70
64
  - Gemfile.lock
71
65
  - README.md
@@ -81,27 +75,26 @@ files:
81
75
  homepage: https://github.com/datariot/omniauth-paypal
82
76
  licenses:
83
77
  - MIT
78
+ metadata: {}
84
79
  post_install_message:
85
80
  rdoc_options: []
86
81
  require_paths:
87
82
  - lib
88
83
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
84
  requirements:
91
85
  - - ! '>='
92
86
  - !ruby/object:Gem::Version
93
87
  version: '0'
94
88
  required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
89
  requirements:
97
90
  - - ! '>='
98
91
  - !ruby/object:Gem::Version
99
92
  version: '0'
100
93
  requirements: []
101
94
  rubyforge_project:
102
- rubygems_version: 1.8.24
95
+ rubygems_version: 2.1.5
103
96
  signing_key:
104
- specification_version: 3
97
+ specification_version: 4
105
98
  summary: PayPal Identity strategy for OmniAuth
106
99
  test_files:
107
100
  - spec/omniauth/strategies/paypal_spec.rb