def authorize(parameters = {}, &block)
      parameters.each_pair do |key, value|
        @credential_handler.set_credential(key, value)
      end

      auth_handler = get_auth_handler()
      token = auth_handler.get_token()

      # If token is invalid ask for a new one.
      if token.nil?
        begin
          credentials = @credential_handler.credentials
          token = auth_handler.get_token(credentials)
        rescue AdsCommon::Errors::OAuth2VerificationRequired => e
          verification_code = (block_given?) ? yield(e.oauth_url) : nil
          # Retry with verification code if one provided.
          if verification_code
            @credential_handler.set_credential(
                :oauth2_verification_code, verification_code)
            retry
          else
            raise e
          end
        end
      end
      return token
    end
def authorize(parameters = {}, &block)
      parameters.each_pair do |key, value|
        @credential_handler.set_credential(key, value)
      end

      auth_handler = get_auth_handler()
      token = auth_handler.get_token()

      # If token is invalid ask for a new one.
      if token.nil?
        begin
          credentials = @credential_handler.credentials
          token = auth_handler.get_token(credentials)
        rescue AdsCommon::Errors::OAuth2VerificationRequired => e
          verification_code = (block_given?) ? yield(e.oauth_url) : nil
          # Retry with verification code if one provided.
          if verification_code
            @credential_handler.set_credential(
                :oauth2_verification_code, verification_code)
            retry
          else
            raise e
          end
        end
      end
      return token
    end
Authorize with specified authentication method.

 Args:
  - parameters - hash of credentials to add to configuration
  - block - code block to handle auth login url

 Returns:
  - Auth token for the method

 Throws:
  - AdsCommon::Errors::AuthError or derived if authetication error has
    occured