docs: def get_credentials(username=None, password=None, netrc=None, use_keyring=False):
      """
      Return valid username, password tuple.
  
      Raises CredentialsError if username or password is missing.
      """
      if netrc:
          path = None if netrc is True else netrc
          return authenticate_through_netrc(path)
  
      if not username:
          raise CredentialsError(
              'Please provide a username with the -u option, '
              'or a .netrc file with the -n option.')
  
      if not password and use_keyring:
          password = keyring.get_password(KEYRING_SERVICE_NAME, username)
  
      if not password:
          password = getpass.getpass('Coursera password for {0}: '.format(username))
          if use_keyring:
              keyring.set_password(KEYRING_SERVICE_NAME, username, password)
  
      return username, password