lib/omniauth/strategies/constantcontact2.rb in omniauth-constantcontact2-1.0.5 vs lib/omniauth/strategies/constantcontact2.rb in omniauth-constantcontact2-1.0.6

- old
+ new

@@ -6,10 +6,11 @@ module Strategies class ConstantContact2 < OmniAuth::Strategies::OAuth2 DEFAULT_RESPONSE_TYPE = 'code' DEFAULT_GRANT = 'authorization_code' + API_PATH = 'https://api.constantcontact.com/v2' option :name, "constantcontact" option :client_options, { :site => 'https://oauth2.constantcontact.com', @@ -35,27 +36,24 @@ uid do request.params['username'] end info do - entries = raw_info['feed']['entry'] - if entries.kind_of?(Array) - { - :email_entries => entries.map{|x|x["content"]["Email"]["EmailAddress"]} - } - else - { - :email => entries["content"]["Email"]["EmailAddress"] - } - end + { + email: raw_info['email'] + } end extra do { 'raw_info' => raw_info } end def raw_info - @raw_info ||= MultiXml.parse(access_token.get("https://api.constantcontact.com/ws/customers/#{request.params['username'].strip}/settings/emailaddresses").body) + options = { + params: {api_key: client.id}, + headers: {'Authorization' => "Bearer #{access_token.token}"} + } + @raw_info ||= JSON.parse(access_token.get("#{API_PATH}/account/info", options).body) end end end end