Yoast\WP\SEO\MyYoast_Client\Application

Token_Revocation_Handler::revokepublicYoast 1.0

Revokes a token at the authorization server.

Метод класса: Token_Revocation_Handler{}

Хуков нет.

Возвращает

true|false. True if the revocation request was sent (regardless of server response).

Использование

$Token_Revocation_Handler = new Token_Revocation_Handler();
$Token_Revocation_Handler->revoke(;

Код Token_Revocation_Handler::revoke() Yoast 28.3

public function revoke(
	// phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+.
	#[SensitiveParameter]
	string $token,
	string $token_type_hint = Token_Type_Hint::REFRESH_TOKEN
): bool {
	try {
		$registered_client = $this->client_registration->get_registered_client();
		if ( $registered_client === null ) {
			return false;
		}
		$revocation_endpoint = $this->discovery->get_document()->get_revocation_endpoint();

		$client_assertion = $this->client_authenticator->create_client_assertion(
			$registered_client->get_client_id(),
			$revocation_endpoint,
		);

		$body = [
			'token'                 => $token,
			'token_type_hint'       => $token_type_hint,
			'client_id'             => $registered_client->get_client_id(),
			'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
			'client_assertion'      => $client_assertion,
		];

		$this->oauth_server_client->request(
			'POST',
			$revocation_endpoint,
			[
				'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded' ],
				'body'    => $body,
				'dpop'    => true,
			],
		);

		return true;
	}
	catch ( Exception $e ) {
		$this->logger->warning(
			'Token revocation failed ({token_type_hint}): {error}',
			[
				'token_type_hint' => $token_type_hint,
				'error'           => $e->getMessage(),
			],
		);
		return false;
	}
}