Class: BTCJammer::OAuth

Inherits:
Object
  • Object
show all
Includes:
OAuth2
Defined in:
lib/btcjammer.rb

Overview

Helper methods around OAuth2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOAuth

Returns a new instance of OAuth.



34
35
36
37
# File 'lib/btcjammer.rb', line 34

def initialize
  @client = Client.new(BTCJam.client_id, BTCJam.client_secret,
                       site: API_PUBLIC_URL)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



33
34
35
# File 'lib/btcjammer.rb', line 33

def client
  @client
end

Class Method Details

.from_token(token) ⇒ Object



48
49
50
51
# File 'lib/btcjammer.rb', line 48

def self.from_token(token)
  auth = OAuth.new
  OAuth2::AccessToken.new(auth.client, token)
end

Instance Method Details

#authorization_urlObject



39
40
41
42
# File 'lib/btcjammer.rb', line 39

def authorization_url
  @client.auth_code.authorize_url(redirect_uri: BTCJam.redirect_uri,
                                  scope: BTCJam.scopes.join(' '))
end

#get_access_token(code) ⇒ Object



44
45
46
# File 'lib/btcjammer.rb', line 44

def get_access_token(code)
  @client.auth_code.get_token(code, redirect_uri: BTCJam.redirect_uri)
end