Class: Forecast::OAuthCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/forecast/credentials.rb

Overview

# def basic_auth

#   Base64.encode64("#{@username}:#{@password}").delete("\r\n")
# end

end

Instance Method Summary collapse

Constructor Details

#initialize(ops = {}) ⇒ OAuthCredentials

Returns a new instance of OAuthCredentials.



26
27
28
29
# File 'lib/forecast/credentials.rb', line 26

def initialize(ops={})
  @access_token = ops[:access_token] || nil
   = ops[:forecast_account_id] || nil
end

Instance Method Details

#hostObject



38
39
40
# File 'lib/forecast/credentials.rb', line 38

def host
  "https://api.forecastapp.com"
end

#set_authentication(request_options) ⇒ Object



31
32
33
34
35
36
# File 'lib/forecast/credentials.rb', line 31

def set_authentication(request_options)
  request_options[:headers] ||= {}
  request_options[:headers]['Forecast-Account-Id'] = 
  request_options[:headers]['Authorization'] = "Bearer #{@access_token}"
  request_options[:headers]['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'
end