def METHOD_NAME(self, username=None, password=None, record=None, cookieAuth=False):
    from tapiriik.auth.credential_storage import CredentialStore
    if record:
        password = CredentialStore.Decrypt(record.ExtendedAuthorization["Password"])
        username = CredentialStore.Decrypt(record.ExtendedAuthorization["Username"])
    session = requests.Session()
    if cookieAuth:
        login_res = session.post(
            "https://www.trainerroad.com/login",
            cookies={"__RequestVerificationToken": "whee"},
            data={"Username": username, "Password": password, "__RequestVerificationToken": "whee"},
            allow_redirects=False
        )
        if login_res.status_code != 302:
            raise APIException("Invalid login %s - %s" % (login_res.status_code, login_res.text), block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
    else:
        session.auth = (username, password)
    return session