Class: Coinbase::Wallet::OAuthClient
- Inherits:
-
NetHTTPClient
- Object
- APIClient
- NetHTTPClient
- Coinbase::Wallet::OAuthClient
- Defined in:
- lib/coinbase/wallet/client.rb
Constant Summary
Constants inherited from APIClient
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #auth_headers(method, path, body) ⇒ Object
- #authorize!(redirect_url, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ OAuthClient
constructor
A new instance of OAuthClient.
- #refresh!(params = {}) ⇒ Object
- #revoke!(params = {}) ⇒ Object
Methods inherited from APIClient
#account, #accounts, #address, #address_transactions, #addresses, #auth_info, #buy, #buy_price, callback_signing_public_key, #callback_signing_public_key, #cancel_request, #checkout, #checkout_orders, #checkouts, #commit_buy, #commit_deposit, #commit_sell, #commit_withdrawal, #complete_request, #create_account, #create_address, #create_checkout, #create_checkout_order, #create_order, #currencies, #current_user, #delete, #delete_account, #deposit, #exchange_rates, #get, #historic_prices, #list_buy, #list_buys, #list_deposit, #list_deposits, #list_sell, #list_sells, #list_withdrawal, #list_withdrawals, #merchant, #notification, #notifications, #order, #orders, #payment_method, #payment_methods, #post, #primary_account, #put, #refund_order, #request, #resend_request, #sell, #sell_price, #send, #set_primary_account, #spot_price, #time, #transaction, #transactions, #transfer, #update_account, #update_current_user, #user, verify_callback, #verify_callback, whitelisted_certificates, #withdraw
Constructor Details
#initialize(options = {}) ⇒ OAuthClient
Returns a new instance of OAuthClient.
32 33 34 35 36 37 38 |
# File 'lib/coinbase/wallet/client.rb', line 32 def initialize(={}) raise unless .has_key? :access_token @access_token = [:access_token] @refresh_token = [:refresh_token] @oauth_uri = URI.parse([:api_url] || BASE_API_URL) super(@oauth_uri, ) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
30 31 32 |
# File 'lib/coinbase/wallet/client.rb', line 30 def access_token @access_token end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
30 31 32 |
# File 'lib/coinbase/wallet/client.rb', line 30 def refresh_token @refresh_token end |
Instance Method Details
#auth_headers(method, path, body) ⇒ Object
40 41 42 43 |
# File 'lib/coinbase/wallet/client.rb', line 40 def auth_headers(method, path, body) { 'Authorization' => "Bearer #{@access_token}", 'CB-VERSION' => API_VERSION } end |
#authorize!(redirect_url, params = {}) ⇒ Object
45 46 47 |
# File 'lib/coinbase/wallet/client.rb', line 45 def (redirect_url, params = {}) raise NotImplementedError end |
#refresh!(params = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/coinbase/wallet/client.rb', line 60 def refresh!(params = {}) params[:grant_type] = 'refresh_token' params[:refresh_token] ||= @refresh_token raise "Missing Parameter: refresh_token" unless params.has_key?(:refresh_token) out = nil post("/oauth/token", params) do |resp| out = APIObject.new(self, resp.body) # Update tokens to current instance # Developer should always persist them @access_token = out.access_token @refresh_token = out.refresh_token yield(out, resp) if block_given? end out end |