def validate_access_token(self):
        """Validate the existing token and refresh token."""
        try:
            __method_name = inspect.currentframe().f_code.co_name
            from_refresh_token = 0
            if self.access_token:
                if self.is_token_expired(self.access_token_expiration) and not self.is_token_expired(
                    self.refresh_token_expiration
                ):
                    self.applogger.info(
                        "{}(method={}) : {} : Access token expired. Generating new access token using refresh token.".format(
                            consts.LOGS_STARTS_WITH, __method_name, self.function_name
                        )
                    )
                    from_refresh_token = 1
                    self.generate_access_token(from_refresh_token)
                elif self.is_token_expired(self.access_token_expiration) and self.is_token_expired(
                    self.refresh_token_expiration
                ):
                    self.applogger.info(
                        "{}(method={}) : {} : Both access token and refresh token are expired or expiration time does not exist.".format(
                            consts.LOGS_STARTS_WITH, __method_name, self.function_name
                        )
                    )
                    self.generate_access_token(from_refresh_token)
                else:
                    self.applogger.info(
                        "{}(method={}) : {} : Using existing and valid access token.".format(
                            consts.LOGS_STARTS_WITH, __method_name, self.function_name
                        )
                    )
            else:
                self.applogger.info(
                    "{}(method={}) : {} : Access token does not exist.Generating new access token and refresh token.".format(
                        consts.LOGS_STARTS_WITH, __method_name, self.function_name
                    )
                )
                self.generate_access_token(from_refresh_token)
        except Exception as err:
            self.applogger.error(
                "{}(method={}) : {} : Error in getting access token. : {}".format(
                    consts.LOGS_STARTS_WITH, __method_name, self.function_name, err
                )
            )
            raise Exception(err)
Validate the existing token and refresh token.
Solutions/Vectra XDR/Data Connectors/VectraDataConnector/SharedCode/collector.py