omniauth-wepay 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +18 -0
- data/lib/omniauth/strategies/wepay.rb +24 -24
- data/lib/omniauth/version.rb +2 -2
- data/lib/wepay.rb +1 -1
- data/omniauth-wepay.gemspec +1 -1
- metadata +1 -1
data/README.markdown
CHANGED
@@ -25,9 +25,27 @@ Here's a quick example, adding the middleware to a Rails app in config/initializ
|
|
25
25
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
26
|
provider :wepay, ENV['APP_ID'], ENV['SECRET']
|
27
27
|
end
|
28
|
+
```
|
29
|
+
|
30
|
+
### Note
|
31
|
+
|
32
|
+
Currently the gem only supports the "stage" endpoints. When you are ready to go into production, modify the omniauth.rb as follows to use the production endpoints:
|
28
33
|
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
|
+
provider :wepay, ENV['APP_ID'], ENV['SECRET'] do |config|
|
38
|
+
config.client_options.authorize_url = "https://www.wepay.com/v2/oauth2/authorize"
|
39
|
+
config.client_options.token_url = "https://www.wepayapi.com/v2/oauth2/token"
|
40
|
+
config.client_options.site = "https://www.wepayapi.com/v2"
|
41
|
+
end
|
42
|
+
end
|
29
43
|
```
|
30
44
|
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
31
49
|
## Contributing
|
32
50
|
|
33
51
|
1. Fork it
|
@@ -4,39 +4,39 @@ module OmniAuth
|
|
4
4
|
module Strategies
|
5
5
|
class Wepay < OmniAuth::Strategies::OAuth2
|
6
6
|
|
7
|
-
|
7
|
+
DEFAULT_PERMISSIONS = "manage_accounts,view_balance,collect_payments,refund_payments,view_user"
|
8
8
|
|
9
9
|
option :fields, [:user_id, :name, :email]
|
10
|
-
|
11
|
-
|
10
|
+
option :uid_field, :user_id
|
11
|
+
option :scope, DEFAULT_PERMISSIONS
|
12
12
|
option :client_options, {
|
13
13
|
:authorize_url => "https://stage.wepay.com/v2/oauth2/authorize",
|
14
|
-
:token_url
|
15
|
-
:site
|
14
|
+
:token_url => "https://stage.wepayapi.com/v2/oauth2/token",
|
15
|
+
:site => "https://stage.wepayapi.com/v2"
|
16
16
|
}
|
17
17
|
|
18
18
|
uid do
|
19
|
-
|
19
|
+
raw_info["user_id"]
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
info do
|
23
|
+
{"email"=> raw_info["email"], "name"=> "#{raw_info['first_name']} #{raw_info['last_name']}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
def raw_info
|
27
|
+
params = {code: request.params['code'], client_id:options.client_id, redirect_uri: callback_url, client_secret: options.client_secret}.to_param
|
28
|
+
url = options.client_options.token_url + "?" + params
|
29
|
+
|
30
|
+
info = access_token.post(url).parsed
|
31
|
+
|
32
|
+
user_url = "https://stage.wepayapi.com/v2/user"
|
33
|
+
info2 = client.request(:post, user_url) do |req|
|
34
|
+
req.headers["Authorization"] = "Bearer #{info["access_token"]}"
|
35
|
+
end.parsed
|
36
|
+
|
37
|
+
@raw_info ||= info.merge(info2)
|
38
|
+
end
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
data/lib/omniauth/version.rb
CHANGED
data/lib/wepay.rb
CHANGED
data/omniauth-wepay.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'omniauth/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'omniauth-wepay'
|
7
|
-
gem.version =
|
7
|
+
gem.version = OmniAuth::Wepay::VERSION
|
8
8
|
gem.authors = ['Volkan Unsal']
|
9
9
|
gem.email = ['spocksplanet@gmail.com']
|
10
10
|
gem.summary = %q{Omniauth strategy for WePay}
|