Yoast\WP\SEO\MyYoast_Client\Application\Grants

Client_Credentials_Grant{}Yoast 1.0└─ Grant_Interface

Grant strategy for the Client Credentials flow (RFC 6749 Section 4.4).

Used for site-level tokens without user context. Includes the site URL for site identity.

Хуков нет.

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

$Client_Credentials_Grant = new Client_Credentials_Grant();
// use class methods

Методы

  1. public __construct( array $scopes, string $site_url )
  2. public get_grant_params()
  3. public get_grant_type()

Код Client_Credentials_Grant{} Yoast 27.7

class Client_Credentials_Grant implements Grant_Interface {

	/**
	 * The scopes to request.
	 *
	 * @var string[]
	 */
	private $scopes;

	/**
	 * The site URL for site identity.
	 *
	 * @var string
	 */
	private $site_url;

	/**
	 * Client_Credentials_Grant constructor.
	 *
	 * @param string[] $scopes   The scopes to request.
	 * @param string   $site_url The site URL.
	 */
	public function __construct( array $scopes, string $site_url ) {
		$this->scopes   = $scopes;
		$this->site_url = $site_url;
	}

	/**
	 * Returns the grant type identifier.
	 *
	 * @return string
	 */
	public function get_grant_type(): string {
		return 'client_credentials';
	}

	/**
	 * Returns the grant-specific parameters.
	 *
	 * @return array<string, string>
	 */
	public function get_grant_params(): array {
		$params = [
			'site_url' => $this->site_url,
		];

		if ( ! empty( $this->scopes ) ) {
			$params['scope'] = \implode( ' ', $this->scopes );
		}

		return $params;
	}
}