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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f69443a60ab099095aa58d742021708f5a786df8
4
- data.tar.gz: f97c7eb92386e879ad37f4bfbb4644d9ea5f8543
3
+ metadata.gz: daa6057596d85430fc79f250e0663875bd401a0d
4
+ data.tar.gz: 3890bc6e04ce856b0d8184d485b736cec67db28a
5
5
  SHA512:
6
- metadata.gz: 32aaa551fd50507cb92cee93eefc2603a7fdb2c26e1c56d619a763417634ef8d00bbc7343d4627c1bf87b3597ec641b642c56679dfc7bf7e943cedfbdadb2d0b
7
- data.tar.gz: fd28d4923c6b8e79c8807b1c78ac08480bff080c858d2d83086ba96aceb15df6433305d27d014945ed02ae1bab1742fd30a93bbafc085d11c571222e9e40a526
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
+ ```
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Coinbase
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -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.0.0
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-26 00:00:00.000000000 Z
12
+ date: 2015-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json