Class: Oauth2Rails::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth2_rails/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/oauth2_rails/response.rb', line 6

def initialize(response)
  @far_resp = response
end

Instance Method Details

#access_tokenObject



38
39
40
# File 'lib/oauth2_rails/response.rb', line 38

def access_token
  json_body['access_token']
end

#bodyObject



18
19
20
# File 'lib/oauth2_rails/response.rb', line 18

def body
  @far_resp.body
end

#error_messageObject



30
31
32
# File 'lib/oauth2_rails/response.rb', line 30

def error_message
  errors['message'] if errors
end

#errorsObject



26
27
28
# File 'lib/oauth2_rails/response.rb', line 26

def errors
  json_body['errors'][0] if status != 200
end

#headersObject



14
15
16
# File 'lib/oauth2_rails/response.rb', line 14

def headers
  @far_resp.headers
end

#json_bodyObject



22
23
24
# File 'lib/oauth2_rails/response.rb', line 22

def json_body
  JSON.parse @far_resp.body
end

#refresh_tokenObject



34
35
36
# File 'lib/oauth2_rails/response.rb', line 34

def refresh_token
  json_body['access_token']
end

#statusObject



10
11
12
# File 'lib/oauth2_rails/response.rb', line 10

def status
  @far_resp.status
end