Yoast\WP\SEO\MyYoast_Client\User_Interface

Auth_Command::statuspublicYoast 1.0

Shows the current MyYoast OAuth client status.

Displays issuer configuration, registration state, and token status without making any network calls. Use the global --user flag to check a specific user's token status.

OPTIONS

[--resource=<uri>]
Show status for a specific RFC 8707 resource indicator. Omit to target the default resource. Cannot be combined with --all-resources.
[--all-resources]
Show status for every stored resource bucket. Cannot be combined with --resource.
[--format=<format>]
Output format.
--- default: table options:
  • table
  • json

EXAMPLES

wp yoast auth status
wp yoast auth status --user=admin
wp yoast auth status --resource=https://ai.yoa.st
wp yoast auth status --all-resources
wp yoast auth status --format=json

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Auth_Command = new Auth_Command();
$Auth_Command->status( $args, $assoc_args ): void;
$args
.
По умолчанию: null
$assoc_args
.
По умолчанию: null

Код Auth_Command::status() Yoast 28.3

public function status( $args = null, $assoc_args = null ): void {
	$user_id = \get_current_user_id();

	$issuer_url        = $this->issuer_config->get_issuer_url();
	$has_software      = ( $this->issuer_config->get_software_statement() !== '' );
	$has_iat           = ( $this->issuer_config->get_initial_access_token() !== '' );
	$is_registered     = $this->myyoast_client->is_registered();
	$client_id         = null;
	$registered_client = $this->client_registration->get_registered_client();

	if ( $registered_client !== null ) {
		$client_id = $registered_client->get_client_id();
	}

	$has_all  = (bool) Utils\get_flag_value( $assoc_args, 'all-resources', false );
	$resource = Utils\get_flag_value( $assoc_args, 'resource' );

	if ( $has_all && $resource !== null && $resource !== '' ) {
		WP_CLI::error( '--all-resources and --resource cannot be combined.' );
	}

	if ( $has_all ) {
		$user_tokens = ( $user_id > 0 ) ? $this->user_token_storage->get_all( $user_id ) : [];
		$site_tokens = $this->token_storage->get_all();
	}
	else {
		try {
			$resource_filter = new Resource_Indicator( ( $resource !== null && $resource !== '' ) ? (string) $resource : null );
		}
		catch ( Invalid_Resource_Exception $e ) {
			WP_CLI::error( 'Invalid resource indicator: ' . $e->getMessage() );
			return;
		}

		$user_tokens = ( $user_id > 0 ) ? \array_filter( [ $this->user_token_storage->get( $user_id, $resource_filter ) ] ) : [];
		$site_tokens = \array_filter( [ $this->token_storage->get( $resource_filter ) ] );
	}

	$format = Utils\get_flag_value( $assoc_args, 'format', 'table' );

	$data = [
		'issuer_url'           => $issuer_url,
		'software_statement'   => ( $has_software ) ? 'configured' : 'not configured',
		'initial_access_token' => ( $has_iat ) ? 'configured' : 'not configured',
		'registered'           => ( $is_registered ) ? 'yes' : 'no',
		'client_id'            => ( $client_id ?? '-' ),
		'user_id'              => ( $user_id > 0 ) ? $user_id : 'none (use --user flag)',
		'user_tokens'          => $this->build_token_inventory( $user_tokens ),
		'site_tokens'          => $this->build_token_inventory( $site_tokens ),
	];

	$this->output( $data, $format );
}