class GirlScout::AccessToken
Attributes
expires_at[R]
Public Class Methods
new(attr = {})
click to toggle source
# File lib/girlscout/access_token.rb, line 32 def initialize(attr = {}) @attributes = normalize_attributes(attr) @expires_at = Time.now + expires_in end
refresh()
click to toggle source
# File lib/girlscout/access_token.rb, line 10 def refresh response = Excon.post( "#{Config.api_prefix}/oauth2/token", body: credential, headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } ) raise GirlScout::Error, JSON.parse(response.body) if response.status >= 400 new(JSON.parse(response.body)) end
Private Class Methods
credential()
click to toggle source
# File lib/girlscout/access_token.rb, line 23 def credential URI.encode_www_form( client_id: Config.client_id, client_secret: Config.client_secret, grant_type: 'client_credentials' ) end
Public Instance Methods
expired?()
click to toggle source
# File lib/girlscout/access_token.rb, line 37 def expired? @expires_at.to_i <= Time.now.to_i end
to_s()
click to toggle source
# File lib/girlscout/access_token.rb, line 41 def to_s access_token end