Class: OmniAuth::Strategies::Fitbit

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/fitbit.rb

Instance Method Summary collapse

Instance Method Details

#basic_auth_headerObject



23
24
25
# File 'lib/omniauth/strategies/fitbit.rb', line 23

def basic_auth_header
  "Basic " + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
end

#build_access_tokenObject



18
19
20
21
# File 'lib/omniauth/strategies/fitbit.rb', line 18

def build_access_token
  options.token_params.merge!(:headers => {'Authorization' => basic_auth_header })
  super
end

#query_stringObject



27
28
29
30
31
# File 'lib/omniauth/strategies/fitbit.rb', line 27

def query_string
  # Using state and code params in the callback_url causes a mismatch with
  # the value set in the fitbit application configuration, so we're skipping them
  ''
end

#raw_infoObject



61
62
63
64
65
66
67
# File 'lib/omniauth/strategies/fitbit.rb', line 61

def raw_info
  if options[:use_english_measure] == 'true'
    @raw_info ||= MultiJson.load(access_token.request('get', 'https://api.fitbit.com/1/user/-/profile.json', { 'Accept-Language' => 'en_US' }).body)
  else
    @raw_info ||= MultiJson.load(access_token.get('https://api.fitbit.com/1/user/-/profile.json').body)
  end
end