Class: ApontadorOauth2::Client
- Inherits:
-
Object
- Object
- ApontadorOauth2::Client
- Defined in:
- lib/apontador_oauth2/client.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #request ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 |
# File 'lib/apontador_oauth2/client.rb', line 9 def initialize() @options = { :grant_type => "client_credentials", :username => "", :password => "", }.merge!() request end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/apontador_oauth2/client.rb', line 8 def @options end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/apontador_oauth2/client.rb', line 8 def token @token end |
Instance Method Details
#request ⇒ Object
18 19 20 21 22 23 |
# File 'lib/apontador_oauth2/client.rb', line 18 def request url = URI.parse(@options[:url]) connection = Faraday.new(:url => url) response = connection.post 'oauth/token', @options @token = JSON.parse(response.body)['access_token'] end |