Class: SmsCandy::Authentication::Strategies::OAuth2

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_candy/authentication/strategies/o_auth_2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



8
9
10
# File 'lib/sms_candy/authentication/strategies/o_auth_2.rb', line 8

def access_token
  @access_token
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



9
10
11
# File 'lib/sms_candy/authentication/strategies/o_auth_2.rb', line 9

def expires_at
  @expires_at
end

Instance Method Details

#authenticate!Object



16
17
18
19
20
21
22
# File 'lib/sms_candy/authentication/strategies/o_auth_2.rb', line 16

def authenticate!
  response = RestClient.get(base_url, { params: authentication_params })

  json_response = JSON.parse response.body
  @expires_at = Time.zone.now + json_response["expires_in"].to_i
  @access_token = json_response["access_token"]
end