class OmniAuth::Strategies::Freshbooks

Constants

API_VERSION

Public Instance Methods

build_access_token() click to toggle source
# File lib/omniauth/strategies/freshbooks.rb, line 56
def build_access_token
  client.auth_code.get_token(
    request.params["code"],
    { redirect_uri: callback_url(false) }.merge(token_params.to_hash(symbolize_keys: true)),
    deep_symbolize(options.auth_token_params)
  )
end
callback_url(include_query_string = true) click to toggle source
# File lib/omniauth/strategies/freshbooks.rb, line 42
def callback_url(include_query_string = true)
  url = full_host + script_name + callback_path

  # Optional inclusion of query_string ensure the access token request redirect_uri is an exact match to the
  # authorized redirect URI defined in FreshBooks
  url += query_string if include_query_string

  # Ensure valid request for localhost because FreshBooks doesn't authorize non ssl callbacks.
  # The ssl response can then be altered from https:// to http:// manually for the purpose of testing.
  # This is limitation is noted in "Redirect URI Limitations" section of their documentation:
  # https://www.freshbooks.com/api/authentication
  url.gsub('http://localhost', 'https://localhost')
end
raw_info() click to toggle source
# File lib/omniauth/strategies/freshbooks.rb, line 36
def raw_info
  @raw_info ||= access_token
                  .get('auth/api/v1/users/me', { headers: { 'Api-Version' => API_VERSION } })
                  .parsed['response']
end