code: def _get_auth(self, force_console=False):
          
          if not self.target:
              raise ValueError("Unspecified target ({!r})".format(self.target))
          elif not force_console and self.URL_RE.match(self.target):
              auth_url = urlparse(self.target)
              source = 'url'
              if auth_url.username:
                  self.user = auth_url.username
              if auth_url.password:
                  self.password = auth_url.password
              if not self.auth_valid():
                  source = self._get_auth_from_keyring()
              if not self.auth_valid():
                  source = self._get_auth_from_netrc(auth_url.hostname)
              if not self.auth_valid():
                  source = self._get_auth_from_console(self.target)
          else:
              source = self._get_auth_from_console(self.target)
  
          if self.auth_valid():
              self.source = source
docs: Try to get login auth from known sources.