def METHOD_NAME(self):
    auth_header = self.request.META.get("HTTP_AUTHORIZATION", None)
    if not auth_header:
        logger.error("Missing Authorization header", extra={'request': self.request})
        raise APIAuthError
    if isinstance(auth_header, str):
        auth_header = auth_header.encode("utf-8")
    try:
        scheme, params = auth_header.split()
        assert scheme.lower() == b"basic"
        decoded_params = base64.b64decode(params)
        username, password = decoded_params.split(b":", 1)
    except Exception:
        logger.error("Invalid basic authentication header", extra={'request': self.request})
        raise APIAuthError
    self.instance = get_object_or_404(Instance, pk=self.kwargs["pk"])
    if (
        constant_time_compare(self.instance.username, username)
        and constant_time_compare(self.instance.get_password(), password)
    ):
        return
    else:
        logger.error("Invalid username or password", extra={'request': self.request})
        raise APIAuthError