def METHOD_NAME(
    self, cred_obj, file_path="", password="", config_assistant=None
):
    """Save credential data to a token file.
    This function will create an encrypted file
    in the user's home directory (~/.timesketch.token by default)
    that contains a stored copy of the credential object.
    Args:
        cred_obj (credentials.TimesketchCredentials): the credential
            object that is to be stored on disk.
        file_path (str): full path to the file storing the saved
            credentials.
        password (str): optional password to encrypt the
            credential file with. If not supplied a password
            will be generated.
        config_assistant (ConfigAssistant): optional configuration
            assistant object. Can be used to store the password to the
            credential file.
    """
    if not file_path:
        file_path = self._filepath
    if password:
        password = bytes(password, "utf-8")
    else:
        password = fernet.Fernet.generate_key()
        if config_assistant:
            config_assistant.set_config("cred_key", password)
            config_assistant.save_config()
    if not os.path.isfile(file_path):
        logger.info("File does not exist, creating it.")
    salt = os.urandom(self.SALT_LENGTH)
    key = self._get_key(salt, password)
    crypto = fernet.Fernet(key)
    data = cred_obj.serialize()
    with open(file_path, "wb") as fw:
        fw.write(salt)
        fw.write(crypto.encrypt(data))
    file_permission = stat.S_IREAD | stat.S_IWRITE
    os.chmod(file_path, file_permission)
    logger.info("Credentials saved to: %s", file_path)