omniauth-paypal-oauth2 1.4.2 → 1.4.3

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: d33993fc27b37c6b3ab9edb748a4bfddb0a7b1c8
4
- data.tar.gz: a687c3aef0412af7ac0afe10a992ed3c79f3bb01
3
+ metadata.gz: 1de40fa2abb67c3e4b4f33983148693a71e78356
4
+ data.tar.gz: 1bb24c1fe181b287bbe7d8beb6c3d8b2e0d27535
5
5
  SHA512:
6
- metadata.gz: 35aa8ae72b8dfa0ea51049a2be778bec487a69cbc3f740cc5b3ea013f722de5f7d83c456e081b3d32037b439ff0a6b8d4c2404dfc39465181a3ed604e88dc383
7
- data.tar.gz: 624b322749d6404fdb5af19037e305f25edf4b912703b95f18ccfe20788a947540a6a5e7f7836344ee4c99afe94d43c8b27b3f7799055164732c24ce4bca1158
6
+ metadata.gz: 98f789936747f04f875010490ba68a9ae7dccaa05abfc11c91e436ee00b05e1ccaec4898335aaaf67c5637fd7a7c75956405bf1802cbe8da61fe95da452c7d78
7
+ data.tar.gz: 54e36224dbf5f61bdc62c8a27ced0799d24ae0c3e31a9000a07f1f84d2a7cac8dc9291ee7c58898b952ee4ad86021f4059d3583ce0526889ecd5a3dae950a20a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-paypal-oauth2 (1.3)
4
+ omniauth-paypal-oauth2 (1.4.2)
5
5
  omniauth-oauth2 (~> 1.4.0)
6
6
 
7
7
  GEM
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jonas Hübotter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,130 +1,232 @@
1
- # OmniAuth PayPal
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-google-oauth2.svg)](https://badge.fury.io/rb/omniauth-google-oauth2)
2
+ [![Build Status](https://travis-ci.org/zquestz/omniauth-google-oauth2.svg)](https://travis-ci.org/zquestz/omniauth-google-oauth2)
2
3
 
3
- **Note:** This gem is designed to work with OmniAuth 1.0 library.
4
4
 
5
- This gem contains the Log In With PayPal strategy for OmniAuth.
5
+ # OmniAuth PayPal OAuth2 Strategy
6
6
 
7
- ## Installing
7
+ Strategy to authenticate with PayPal via OmniAuth.
8
+
9
+ Get your API key at: https://developer.paypal.com/developer/applications/ in the section **RESTApps**. Note the Client ID and the Client Secret.
10
+
11
+ **Note**: You generate separate keys for development (sandbox) and production (live) with each application you register.
12
+ Use the [config Gem](https://rubygems.org/gems/config) to organize your keys and keep them save.
13
+
14
+ For more details, read the PayPal docs: https://developer.paypal.com/docs/integration/direct/identity/
15
+
16
+
17
+ ## Installation
8
18
 
9
19
  Add to your `Gemfile`:
10
20
 
11
21
  ```ruby
12
- gem "omniauth-paypal"
22
+ gem "omniauth-paypal-oauth2"
13
23
  ```
14
24
 
15
- Then `bundle install`.
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install omniauth-paypal-oauth2
32
+
33
+
34
+ ## PayPal API Setup
35
+
36
+ * Go to 'https://developer.paypal.com/developer/applications/'
37
+ * Select your project.
38
+ * Scroll down to 'APP SETTINGS' for each 'SANDBOX' and 'LIVE'.
39
+ * Set `<YOURDOMAIN>/users/auth/paypal_oauth2/callback` as Return URL.
40
+ * Make sure "Log In with PayPal" is enabled and Save.
41
+ * Go to Credentials, then select the "OAuth consent screen" tab on top, and provide an 'EMAIL ADDRESS' and a 'PRODUCT NAME'
42
+ * Wait 10 minutes for changes to take effect.
43
+
16
44
 
17
45
  ## Usage
18
46
 
19
- Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`.
47
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
20
48
 
21
49
  ```ruby
22
50
  Rails.application.config.middleware.use OmniAuth::Builder do
23
- provider :paypal, ENV['APP_ID'], ENV['APP_TOKEN'], sandbox: true, scope: "openid profile email"
51
+ provider :paypal_oauth2, ENV["PAYPAL_CLIENT_ID"], ENV["PAYPAL_CLIENT_SECRET"]
24
52
  end
25
53
  ```
26
54
 
27
- ## Attributes and Scopes
55
+ You can now access the OmniAuth PayPal OAuth2 URL: `/auth/paypal_oauth2`
28
56
 
29
- Log In With PayPal information can be found on https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/
57
+ **Note**: While developing your application, if you change the scope in the initializer you will need to restart your app server. Remember that either the 'email' or 'profile' scope is required!
30
58
 
31
- The possible attributes to be returned at the moment are:
59
+
60
+ ## Configuration
61
+
62
+ If you click from your [Applications Dashboard](https://developer.paypal.com/developer/applications/) in your Application on "Advanced Options" in the "APP SETTINGS" section and "Log In with PayPal" subsection, you can configure several options:
63
+
64
+ * `Basic authentication`: The unique identifier PPID (PayPal ID) is provided. No additional customer information. **Not customizale**.
65
+
66
+ * `Personal Information`:
67
+ * `Full name`: Permits the Name of the customer.
68
+ * `Date of birth`: Permits the date of birth of the customer.
69
+ * `Age range`: Permits an approximate age range of the customer.
70
+
71
+ * `Address Information`:
72
+ * `Email address`: Permits the email address of the customer.
73
+ * `Street address`: Permits the street address of the customer (Street name, House number).
74
+ * `City`: Permits the city name where the customer resides.
75
+ * `State`: Permits the state in which the city is located.
76
+ * `Country`: Permits the country in which both state and city are located.
77
+ * `Zip code`: Permits the Zip code of the customer.
78
+ * `Phone`: Permits the phone number of the customer.
79
+
80
+ * `Account Information`:
81
+ * `Account status (verified)`: Permits a boolean which indicates whether the customer is verified by PayPal or not.
82
+ * `Account type`: Permits a string which indicates the account type of the PayPal customer (e.g.: PERSONAL, BUSINESS).
83
+ * `Account creation date`: Permits the date on which the PayPal account got created.
84
+ * `Time zone`: Permits the time zone in which the PayPal customer is located.
85
+ * `Locale`: Permits a locale string which indicates where the PayPal customer is.
86
+ * `Language`: Permits the language the customer uses on PayPal.
87
+
88
+
89
+ ## Auth Hash
90
+
91
+ Here's an example of an authentication hash available in the callback by accessing `request.env["omniauth.auth"]`:
32
92
 
33
93
  ```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']
94
+ {
95
+ provider: "paypal",
96
+ uid: "bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw",
97
+ info: {
98
+ name: "John Smith",
99
+ email: "example@example.com",
100
+ first_name: "John",
101
+ last_name: "Smith",
102
+ given_name: "John",
103
+ family_name: "Smith",
104
+ location: "Moscow",
105
+ phone: "71234567890"
106
+ },
107
+ credentials: {
108
+ token: "token",
109
+ refresh_token: "refresh_token",
110
+ expires_at: 1355082790,
111
+ expires: true
112
+ },
113
+ extra: {
114
+ account_creation_date: "2008-04-21",
115
+ account_type: "PERSONAL",
116
+ user_id: "https://www.paypal.com/webapps/auth/identity/user/bathjJwvdhKjgfgh8Jd745J7dh5Qkgflbnczd65dfnw",
117
+ address: {
118
+ country: "US",
119
+ locality: "San Jose",
120
+ postal_code: "95131",
121
+ region: "CA",
122
+ street_address: "1 Main St"
123
+ },
124
+ language: "en_US",
125
+ locale: "en_US",
126
+ verified_account: true,
127
+ zoneinfo: "America/Los_Angeles",
128
+ age_range: "31-35",
129
+ birthday: "1982-01-01"
130
+ }
131
+ }
55
132
  ```
56
133
 
57
- The actual set of attributes returned depends on the scopes set. The currently available scopes are:
134
+ For more details see the PayPal [List Of Attributes](https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#attributes).
135
+
136
+
137
+ ### Devise
138
+
139
+ First define your application id and secret in `config/initializers/devise.rb`. Do not use the snippet mentioned in the [Usage](https://github.com/jonhue/omniauth-paypal-oauth2#usage) section.
58
140
 
141
+ Configuration options can be passed as the last parameter here as key/value pairs.
142
+
143
+ ```ruby
144
+ config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET", { }
59
145
  ```
60
- openid
61
- profile
62
- email
63
- address
64
- phone
65
- https://uri.paypal.com/services/paypalattributes
66
- https://uri.paypal.com/services/expresscheckout
146
+
147
+ Then add the following to 'config/routes.rb' so the callback routes are defined.
148
+
149
+ ```ruby
150
+ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
67
151
  ```
68
152
 
69
- (those last 2 are scope names, not links)
70
-
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).
72
-
73
- ## Registering for an API key
74
-
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.
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.
78
-
79
- ## Example of result auth hash
80
- With all scopes requested.
81
-
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"
153
+ Make sure your model is omniauthable. Generally this is "/app/models/user.rb"
154
+
155
+ ```ruby
156
+ devise :omniauthable, :omniauth_providers => [:paypal_oauth2]
116
157
  ```
117
158
 
118
- ## Contributing
159
+ Then make sure your callbacks controller is setup.
160
+
161
+ ```ruby
162
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
163
+ def paypal_oauth2
164
+ # You need to implement the method below in your model (e.g. app/models/user.rb)
165
+ @user = User.from_omniauth(request.env["omniauth.auth"])
166
+
167
+ if @user.persisted?
168
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "PayPal"
169
+ sign_in_and_redirect @user, :event => :authentication
170
+ else
171
+ session["devise.paypal_data"] = request.env["omniauth.auth"]
172
+ redirect_to new_user_registration_url
173
+ end
174
+ end
175
+ end
176
+ ```
177
+
178
+ and bind to or create the user
179
+
180
+ ```ruby
181
+ def self.from_omniauth(access_token)
182
+ data = access_token.info
183
+ user = User.where(:email => data["email"]).first
184
+
185
+ # Uncomment the section below if you want users to be created if they don't exist
186
+ # unless user
187
+ # user = User.create(name: data["name"],
188
+ # email: data["email"],
189
+ # password: Devise.friendly_token[0,20]
190
+ # )
191
+ # end
192
+ user
193
+ end
194
+ ```
195
+
196
+ For your views you can login using:
197
+
198
+ ```erb
199
+ <%= link_to "Sign in with PayPal", user_paypal_oauth2_omniauth_authorize_path %>
200
+
201
+ <%# Devise prior 4.1.0: %>
202
+ <%= link_to "Sign in with PayPal", user_omniauth_authorize_path(:paypal_oauth2) %>
203
+ ```
204
+
205
+ An overview is available at https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
119
206
 
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!
121
207
 
122
208
  ## License
123
209
 
124
- Copyright (c) 2011 by veloGraf Systems
210
+ MIT License
211
+
212
+ Copyright (c) 2017 Jonas Hübotter
213
+
214
+ Permission is hereby granted, free of charge, to any person obtaining a copy
215
+ of this software and associated documentation files (the "Software"), to deal
216
+ in the Software without restriction, including without limitation the rights
217
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
218
+ copies of the Software, and to permit persons to whom the Software is
219
+ furnished to do so, subject to the following conditions:
125
220
 
126
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
221
+ The above copyright notice and this permission notice shall be included in all
222
+ copies or substantial portions of the Software.
127
223
 
128
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
224
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
225
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
226
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
227
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
228
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
229
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
230
+ SOFTWARE.
129
231
 
130
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
232
+ <i>Original PayPal Omniauth Strategy: Copyright (c) 2011 by veloGraf Systems</i>
@@ -1,13 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path('../lib', __FILE__)
3
- require 'omniauth/paypal/version'
3
+ require 'omniauth/paypal_oauth2/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'omniauth-paypal-oauth2'
7
- s.version = '1.4.2'
7
+ s.version = '1.4.3'
8
8
  s.authors = ['Jonas Hübotter']
9
9
  s.email = ['jonas.huebotter@gmail.com']
10
- s.summary = 'PayPal Identity strategy for OmniAuth2'
10
+ s.summary = 'A PayPal OAuth2 strategy for OmniAuth 1.x'
11
11
  s.homepage = 'https://github.com/jonhue/omniauth-paypal-oauth2'
12
12
  s.license = 'MIT'
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-paypal-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
@@ -62,6 +62,7 @@ files:
62
62
  - ".gitignore"
63
63
  - Gemfile
64
64
  - Gemfile.lock
65
+ - LICENSE
65
66
  - README.md
66
67
  - Rakefile
67
68
  - lib/omniauth-paypal-oauth2.rb
@@ -95,5 +96,5 @@ rubyforge_project:
95
96
  rubygems_version: 2.6.8
96
97
  signing_key:
97
98
  specification_version: 4
98
- summary: PayPal Identity strategy for OmniAuth2
99
+ summary: A PayPal OAuth2 strategy for OmniAuth 1.x
99
100
  test_files: []