omniauth-paypal-oauth2 1.4.15 → 2.0.0
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.
- checksums.yaml +4 -4
- data/README.md +34 -49
- data/lib/omniauth/paypal_oauth2/version.rb +1 -1
- data/lib/omniauth/strategies/paypal_oauth2.rb +8 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dfa9136b8e815a484605df0867003a2b272b27dee91ae6b8a9e900c7765b246
|
4
|
+
data.tar.gz: 88f2ac99df28dd63fb83c02e301c065dc504753b5c5f134bd708387e07e6944e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a912c2a22c5afc05e9fe535a1937ab68625e1dd0bc7b4bc4732d54750d9828accee16651df25cce65a8e6f05a59d05a968dd09b933c253f855dcf87bf1a462
|
7
|
+
data.tar.gz: 49bb670b8e5f275743ac03b06e5ab0d22dca281f4f2f489f192dbd4ae274343d3ae6c514edac4be771b746f1e9d1a3d15807d7c294fe7501e7fbe52f3732b0ee
|
data/README.md
CHANGED
@@ -91,13 +91,13 @@ config.omniauth :paypal_oauth2, 'PAYPAL_CLIENT_ID', 'PAYPAL_CLIENT_SECRET'
|
|
91
91
|
Then add the following to 'config/routes.rb' so the callback routes are defined.
|
92
92
|
|
93
93
|
```ruby
|
94
|
-
devise_for :users, :
|
94
|
+
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
|
95
95
|
```
|
96
96
|
|
97
97
|
Make sure your model is omniauthable. Generally this is `'/app/models/user.rb'`
|
98
98
|
|
99
99
|
```ruby
|
100
|
-
devise :omniauthable, :
|
100
|
+
devise :omniauthable, omniauth_providers: [:paypal_oauth2]
|
101
101
|
```
|
102
102
|
|
103
103
|
Then make sure your callbacks controller is setup.
|
@@ -109,8 +109,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
109
109
|
@user = User.from_omniauth(request.env['omniauth.auth'])
|
110
110
|
|
111
111
|
if @user.persisted?
|
112
|
-
flash[:notice] = I18n.t
|
113
|
-
sign_in_and_redirect
|
112
|
+
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: 'PayPal')
|
113
|
+
sign_in_and_redirect(@user, event: :authentication)
|
114
114
|
else
|
115
115
|
session['devise.paypal_data'] = request.env['omniauth.auth']
|
116
116
|
redirect_to new_user_registration_url
|
@@ -124,7 +124,7 @@ and bind to or create the user
|
|
124
124
|
```ruby
|
125
125
|
def self.from_omniauth(access_token)
|
126
126
|
data = access_token.info
|
127
|
-
user = User.where(:
|
127
|
+
user = User.where(email: data['email']).first
|
128
128
|
|
129
129
|
# Uncomment the section below if you want users to be created if they don't exist
|
130
130
|
# unless user
|
@@ -156,8 +156,6 @@ If you click from your [Applications Dashboard](https://developer.paypal.com/dev
|
|
156
156
|
|
157
157
|
* `Personal Information`:
|
158
158
|
* `Full name`: Permits the Name of the customer.
|
159
|
-
* `Date of birth`: Permits the date of birth of the customer.
|
160
|
-
* `Age range`: Permits an approximate age range of the customer.
|
161
159
|
|
162
160
|
* `Address Information`:
|
163
161
|
* `Email address`: Permits the email address of the customer.
|
@@ -166,15 +164,9 @@ If you click from your [Applications Dashboard](https://developer.paypal.com/dev
|
|
166
164
|
* `State`: Permits the state in which the city is located.
|
167
165
|
* `Country`: Permits the country in which both state and city are located.
|
168
166
|
* `Zip code`: Permits the Zip code of the customer.
|
169
|
-
* `Phone`: Permits the phone number of the customer.
|
170
167
|
|
171
168
|
* `Account Information`:
|
172
169
|
* `Account status (verified)`: Permits a boolean which indicates whether the customer is verified by PayPal or not.
|
173
|
-
* `Account type`: Permits a string which indicates the account type of the PayPal customer (e.g.: PERSONAL, BUSINESS).
|
174
|
-
* `Account creation date`: Permits the date on which the PayPal account got created.
|
175
|
-
* `Time zone`: Permits the time zone in which the PayPal customer is located.
|
176
|
-
* `Locale`: Permits a locale string which indicates where the PayPal customer is.
|
177
|
-
* `Language`: Permits the language the customer uses on PayPal.
|
178
170
|
|
179
171
|
### Auth Hash
|
180
172
|
|
@@ -182,46 +174,39 @@ Here's an example of an authentication hash available in the callback by accessi
|
|
182
174
|
|
183
175
|
```ruby
|
184
176
|
{
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
177
|
+
provider: 'paypal',
|
178
|
+
uid: 'bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw',
|
179
|
+
info: {
|
180
|
+
name: 'John Smith',
|
181
|
+
email: 'example@example.com',
|
182
|
+
location: 'Moscow'
|
183
|
+
},
|
184
|
+
credentials: {
|
185
|
+
token: 'token',
|
186
|
+
refresh_token: 'refresh_token',
|
187
|
+
expires_at: 1355082790,
|
188
|
+
expires: true
|
189
|
+
},
|
190
|
+
extra: {
|
191
|
+
account_creation_date: '2008-04-21',
|
192
|
+
account_type: 'PERSONAL',
|
193
|
+
user_id: 'https://www.paypal.com/webapps/auth/identity/user/bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw',
|
194
|
+
address: {
|
195
|
+
country: 'US',
|
196
|
+
locality: 'San Jose',
|
197
|
+
postal_code: '95131',
|
198
|
+
region: 'CA',
|
199
|
+
street_address: '1 Main St'
|
196
200
|
},
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
},
|
203
|
-
extra: {
|
204
|
-
account_creation_date: '2008-04-21',
|
205
|
-
account_type: 'PERSONAL',
|
206
|
-
user_id: 'https://www.paypal.com/webapps/auth/identity/user/bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw',
|
207
|
-
address: {
|
208
|
-
country: 'US',
|
209
|
-
locality: 'San Jose',
|
210
|
-
postal_code: '95131',
|
211
|
-
region: 'CA',
|
212
|
-
street_address: '1 Main St'
|
213
|
-
},
|
214
|
-
language: 'en_US',
|
215
|
-
locale: 'en_US',
|
216
|
-
verified_account: true,
|
217
|
-
zoneinfo: 'America/Los_Angeles',
|
218
|
-
age_range: '31-35',
|
219
|
-
birthday: '1982-01-01'
|
220
|
-
}
|
201
|
+
language: 'en_US',
|
202
|
+
locale: 'en_US',
|
203
|
+
verified_account: true,
|
204
|
+
zoneinfo: 'America/Los_Angeles'
|
205
|
+
}
|
221
206
|
}
|
222
207
|
```
|
223
208
|
|
224
|
-
For more details see the PayPal [List Of Attributes](https://developer.paypal.com/
|
209
|
+
For more details see the PayPal [List Of Attributes](https://developer.paypal.com/docs/api/identity/v1/#userinfo).
|
225
210
|
|
226
211
|
---
|
227
212
|
|
@@ -5,7 +5,7 @@ require 'omniauth-oauth2'
|
|
5
5
|
module OmniAuth
|
6
6
|
module Strategies
|
7
7
|
class PaypalOauth2 < OmniAuth::Strategies::OAuth2
|
8
|
-
DEFAULT_SCOPE = 'email
|
8
|
+
DEFAULT_SCOPE = 'openid email profile'
|
9
9
|
DEFAULT_RESPONSE_TYPE = 'code'
|
10
10
|
SANDBOX_SITE = 'https://api.sandbox.paypal.com'
|
11
11
|
SANDBOX_AUTHORIZE_URL = 'https://www.sandbox.paypal.com/signin/authorize'
|
@@ -30,13 +30,10 @@ module OmniAuth
|
|
30
30
|
info do
|
31
31
|
prune!(
|
32
32
|
'name' => raw_info['name'],
|
33
|
-
'email' => raw_info['
|
34
|
-
|
35
|
-
|
36
|
-
'
|
37
|
-
'family_name' => raw_info['family_name'],
|
38
|
-
'location' => (raw_info['address'] || {})['locality'],
|
39
|
-
'phone' => raw_info['phone_number']
|
33
|
+
'email' => (raw_info['emails'].detect do |email|
|
34
|
+
email['primary']
|
35
|
+
end || {})['value'],
|
36
|
+
'location' => (raw_info['address'] || {})['locality']
|
40
37
|
)
|
41
38
|
end
|
42
39
|
|
@@ -49,9 +46,7 @@ module OmniAuth
|
|
49
46
|
'language' => raw_info['language'],
|
50
47
|
'zoneinfo' => raw_info['zoneinfo'],
|
51
48
|
'locale' => raw_info['locale'],
|
52
|
-
'account_creation_date' => raw_info['account_creation_date']
|
53
|
-
'age_range' => raw_info['age_range'],
|
54
|
-
'birthday' => raw_info['birthday']
|
49
|
+
'account_creation_date' => raw_info['account_creation_date']
|
55
50
|
)
|
56
51
|
end
|
57
52
|
|
@@ -81,11 +76,11 @@ module OmniAuth
|
|
81
76
|
private
|
82
77
|
|
83
78
|
def load_identity
|
84
|
-
access_token.options[:mode] = :
|
79
|
+
access_token.options[:mode] = :header
|
85
80
|
access_token.options[:param_name] = :access_token
|
86
81
|
access_token.options[:grant_type] = :authorization_code
|
87
82
|
access_token.get(
|
88
|
-
'/v1/identity/
|
83
|
+
'/v1/identity/oauth2/userinfo', params: { schema: 'paypalv1.1' }
|
89
84
|
).parsed || {}
|
90
85
|
end
|
91
86
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-paypal-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|