omniauth-coinbase 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/omniauth-coinbase/version.rb +1 -1
- data/lib/omniauth/strategies/coinbase.rb +30 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa6057596d85430fc79f250e0663875bd401a0d
|
4
|
+
data.tar.gz: 3890bc6e04ce856b0d8184d485b736cec67db28a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba18d06c321536d7d9e7baa6a2f9276062ce06d0e38014ab70bf15535bc9c7267c64b89e6b5dde92cca6afe46498c7f7f0040ba563dee000e737525a193c668d
|
7
|
+
data.tar.gz: a11addfef277f99705a08a391e07be0f2e8ced02a9d9bf76ab38b1bae39ea9318a8066d822ec45bb0e90e0699fcc99a384d374fd874656ed1e9e82b4eff9f3b0
|
data/README.md
CHANGED
@@ -56,3 +56,20 @@ auth.info.name # "Alex Ianus"
|
|
56
56
|
auth.extra.raw_info.email # "aianus@example.com", only present with wallet:user:email scope
|
57
57
|
auth.extra.raw_info.time_zone # "Pacific Time (US & Canada)", only present with wallet:user:show scope
|
58
58
|
```
|
59
|
+
|
60
|
+
# Sandbox support
|
61
|
+
|
62
|
+
Use omniauth-coinbase in development with our [developer sandbox](https://developers.coinbase.com/blog/2015/02/20/sandbox)
|
63
|
+
|
64
|
+
Note that you will need to create a separate sandbox OAuth application with its own client_id and secret.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
68
|
+
provider :coinbase, ENV["COINBASE_CLIENT_ID"], ENV["COINBASE_CLIENT_SECRET"], scope: 'wallet:user:read', sandbox: true
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
require 'coinbase/wallet'
|
74
|
+
client = Coinbase::Wallet::Client.new(api_key: <sandbox api key>, api_secret: <sandbox api secret>, api_url: "https://api.sandbox.coinbase.com")
|
75
|
+
```
|
@@ -4,11 +4,23 @@ require 'coinbase/wallet'
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
6
|
class Coinbase < OmniAuth::Strategies::OAuth2
|
7
|
+
SANDBOX_URLS = {
|
8
|
+
:site => 'https://sandbox.coinbase.com',
|
9
|
+
:api => 'https://api.sandbox.coinbase.com',
|
10
|
+
:authorize_url => 'https://sandbox.coinbase.com/oauth/authorize',
|
11
|
+
:token_url => 'https://sandbox.coinbase.com/oauth/token',
|
12
|
+
}
|
13
|
+
PRODUCTION_URLS = {
|
14
|
+
:site => 'https://www.coinbase.com',
|
15
|
+
:api => 'https://api.coinbase.com',
|
16
|
+
:authorize_url => 'https://www.coinbase.com/oauth/authorize',
|
17
|
+
:token_url => 'https://www.coinbase.com/oauth/token',
|
18
|
+
}
|
19
|
+
|
20
|
+
# Options
|
7
21
|
option :name, 'coinbase'
|
22
|
+
option :sandbox, false
|
8
23
|
option :client_options, {
|
9
|
-
:site => 'https://www.coinbase.com',
|
10
|
-
:authorize_url => 'https://www.coinbase.com/oauth/authorize',
|
11
|
-
:token_url => 'https://www.coinbase.com/oauth/token',
|
12
24
|
:proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil,
|
13
25
|
:ssl => {
|
14
26
|
:verify => true,
|
@@ -17,7 +29,6 @@ module OmniAuth
|
|
17
29
|
}
|
18
30
|
option :authorize_options, [:scope, :meta]
|
19
31
|
|
20
|
-
|
21
32
|
uid { raw_info.id }
|
22
33
|
|
23
34
|
info do
|
@@ -32,11 +43,25 @@ module OmniAuth
|
|
32
43
|
end
|
33
44
|
|
34
45
|
def raw_info
|
35
|
-
client = ::Coinbase::Wallet::OAuthClient.new(access_token: access_token.token)
|
46
|
+
client = ::Coinbase::Wallet::OAuthClient.new(access_token: access_token.token, api_url: options.sandbox ? SANDBOX_URLS[:api] : PRODUCTION_URLS[:api])
|
36
47
|
@raw_info ||= client.current_user
|
37
48
|
rescue ::Errno::ETIMEDOUT
|
38
49
|
raise ::Timeout::Error
|
39
50
|
end
|
51
|
+
|
52
|
+
def request_phase
|
53
|
+
load_coinbase_urls
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def callback_phase
|
58
|
+
load_coinbase_urls
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_coinbase_urls
|
63
|
+
options.client_options = (options.sandbox ? SANDBOX_URLS : PRODUCTION_URLS).merge(options.client_options)
|
64
|
+
end
|
40
65
|
end
|
41
66
|
end
|
42
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-coinbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Palhas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
12
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|