Yoast\WP\SEO\MyYoast_Client\User_Interface
Auth_Command::authorize
Authorizes with MyYoast using the authorization code flow or client credentials.
Without --site, starts the user authorization code flow:
- Run without --code to get the authorization URL.
- Visit the URL in a browser and authorize.
- Copy the code and state from the callback URL.
- Run again with --code and --state to exchange for tokens.
With --site, performs a client_credentials grant for a site-level token.
OPTIONS
- [--site]
- Use client_credentials grant for a site-level token (no browser needed).
- [--scopes=<scopes>]
- Comma-separated scopes to request.
- [--resource=<uri>]
- RFC 8707 resource indicator to bind the token to (e.g. https://ai.yoa.st). Omit for the default resource.
- [--code=<code>]
- Authorization code from the callback URL (user flow phase 2).
- [--state=<state>]
- State parameter from the callback URL (user flow phase 2).
- [--url-only]
- Only print the authorization URL without instructions (user flow phase 1).
- [--format=<format>]
- Output format.
--- default: table options:
- table
- json
EXAMPLES
# Site-level token (client_credentials): wp yoast auth authorize --site --scopes=service:analytics
# Site-level token for a non-default resource: wp yoast auth authorize --site --resource=https://ai.yoa.st --scopes=service:ai:consume
# User authorization code flow, phase 1 - get the URL: wp yoast auth authorize --user=admin --scopes=openid,profile
# User authorization code flow, phase 2 - exchange the code: wp yoast auth authorize --user=admin --code=abc123 --state=xyz789
Метод класса: Auth_Command{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Auth_Command = new Auth_Command(); $Auth_Command->authorize( $args, $assoc_args ): void;
- $args
- .
По умолчанию:null - $assoc_args
- .
По умолчанию:null
Код Auth_Command::authorize() Auth Command::authorize Yoast 28.3
public function authorize( $args = null, $assoc_args = null ): void {
$scopes = $this->parse_scopes( $assoc_args );
$format = Utils\get_flag_value( $assoc_args, 'format', 'table' );
$resource = Utils\get_flag_value( $assoc_args, 'resource' );
$resource_indicator = ( $resource !== null && $resource !== '' ) ? (string) $resource : null;
if ( Utils\get_flag_value( $assoc_args, 'site', false ) ) {
$this->authorize_site( $scopes, $resource_indicator, $format );
return;
}
$this->authorize_user( $assoc_args, $scopes, $resource_indicator, $format );
}