code: def authenticate(self, provider, creds=None, cookies=None):
      
      cookies = cookies or Cookies.global_instance()
  
      if not provider:
        raise BasicAuthException('No basic auth provider specified.')
  
      provider_config = self.get_options().providers.get(provider)
      if not provider_config:
        raise BasicAuthException('No config found for provider {}.'.format(provider))
  
      url = provider_config.get('url')
      if not url:
        raise BasicAuthException('No url found in config for provider {}.'.format(provider))
      if not self.get_options().allow_insecure_urls and not url.startswith('https://'):
        raise BasicAuthException('Auth url for provider {} is not secure: {}.'.format(provider, url))
  
      if creds:
        auth = requests.auth.HTTPBasicAuth(creds.username, creds.password)
      else:
        auth = None  # requests will use the netrc creds.
      response = requests.get(url, auth=auth)
  
      if response.status_code != requests.codes.ok:
        if response.status_code == requests.codes.unauthorized:
          parsed = www_authenticate.parse(response.headers.get('WWW-Authenticate', ''))
          if 'Basic' in parsed:
            raise Challenged(url, response.status_code, response.reason, parsed['Basic']['realm'])
        raise BasicAuthException(url, response.status_code, response.reason)
  
      cookies.update(response.cookies)
docs: Authenticate against the specified provider.
  
      :param str provider: Authorize against this provider.
      :param pants.auth.basic_auth.BasicAuthCreds creds: The creds to use.
        If unspecified, assumes that creds are set in the netrc file.
      :param pants.auth.cookies.Cookies cookies: Store the auth cookies in this instance.
        If unspecified, uses the global instance.
      :raises pants.auth.basic_auth.BasicAuthException: If auth fails due to misconfiguration or
        rejection by the server.