def retrieve_updated_data(api_url, client_id, client_secret)

      options = {
        :api_version => API_VERSION,
        :open_timeout => DEFAULT_OPEN_TIMEOUT,
        :request_timeout => DEFAULT_REQUEST_TIMEOUT,
        :filter_params => [:client_secret] }
      url = URI.parse(api_url)

      success = false
      wait = 5

      while !success do

        begin
          data = nil
          http_client = RightScale::BalancedHttpClient.new([url.to_s], options)
          response = http_client.post("/oauth2", {
            :client_id => client_id.to_s,
            :client_secret => client_secret,
            :grant_type => "client_credentials" } )
          response = RightScale::SerializationHelper.symbolize_keys(response)
          access_token = response[:access_token]
          raise "Could not authorized on #{api_url} using oauth2" if access_token.nil?

          response = http_client.get("/user_data", {
            :client_id => client_id.to_s,
            :client_secret => client_secret },
             { :headers => {"Authorization" => "Bearer #{access_token}" } })
          data = response.to_s
          close_message = "Got updated user metadata. Continue."
          success = true
        rescue RightScale::HttpExceptions::ResourceNotFound => e
          if e.to_s =~ /No route matches "\/api\/user_data"/
            data = ''
            close_message = "Rightscale does not support user metadata update. Skipping."
            success = true
          else
            logger.error "Error: #{e.message}"
            close_message = e
          end
        rescue Exception => e
          if e.to_s =~ /Couldn't find ExtraUserData with key = #{client_id}/
            data = ''
            close_message = "No Updated userdata exists"
            success = true
          else
            logger.error "Error: #{e.message}"
            close_message = e.message
          end
        ensure
          http_client.close(close_message) if http_client
        end

        unless success
          logger.error "Sleeping #{wait} seconds before retry"
          sleep(wait) unless success
          wait = [wait * 2, MAX_WAIT_INTERVAL].min
        end
      end

      return data
    end
def retrieve_updated_data(api_url, client_id, client_secret)

      options = {
        :api_version => API_VERSION,
        :open_timeout => DEFAULT_OPEN_TIMEOUT,
        :request_timeout => DEFAULT_REQUEST_TIMEOUT,
        :filter_params => [:client_secret] }
      url = URI.parse(api_url)

      success = false
      wait = 5

      while !success do

        begin
          data = nil
          http_client = RightScale::BalancedHttpClient.new([url.to_s], options)
          response = http_client.post("/oauth2", {
            :client_id => client_id.to_s,
            :client_secret => client_secret,
            :grant_type => "client_credentials" } )
          response = RightScale::SerializationHelper.symbolize_keys(response)
          access_token = response[:access_token]
          raise "Could not authorized on #{api_url} using oauth2" if access_token.nil?

          response = http_client.get("/user_data", {
            :client_id => client_id.to_s,
            :client_secret => client_secret },
             { :headers => {"Authorization" => "Bearer #{access_token}" } })
          data = response.to_s
          close_message = "Got updated user metadata. Continue."
          success = true
        rescue RightScale::HttpExceptions::ResourceNotFound => e
          if e.to_s =~ /No route matches "\/api\/user_data"/
            data = ''
            close_message = "Rightscale does not support user metadata update. Skipping."
            success = true
          else
            logger.error "Error: #{e.message}"
            close_message = e
          end
        rescue Exception => e
          if e.to_s =~ /Couldn't find ExtraUserData with key = #{client_id}/
            data = ''
            close_message = "No Updated userdata exists"
            success = true
          else
            logger.error "Error: #{e.message}"
            close_message = e.message
          end
        ensure
          http_client.close(close_message) if http_client
        end

        unless success
          logger.error "Sleeping #{wait} seconds before retry"
          sleep(wait) unless success
          wait = [wait * 2, MAX_WAIT_INTERVAL].min
        end
      end

      return data
    end
Retrieve new user-data from RightApi

 @param [String] RigthtApi url
 @param [String] Client ID
 @param [String] Client Secret
 @param [Block] Yield on block with retieved data

 @return [TrueClass] always true