Yoast\WP\SEO\Config

Wincher_PKCE_Provider::getAccessToken()publicYoast 1.0

Requests an access token using a specified grant and option set.

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

Хуков нет.

Возвращает

AccessToken|AccessTokenInterface. The access token.

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

$Wincher_PKCE_Provider = new Wincher_PKCE_Provider();
$Wincher_PKCE_Provider->getAccessToken( $grant, $options );
$grant(разное) (обязательный)
The grant to request access for.
$options(массив)
The options to use with the current request.
По умолчанию: []

Код Wincher_PKCE_Provider::getAccessToken() Yoast 19.11

public function getAccessToken( $grant, array $options = [] ) {
	$grant = $this->verifyGrant( $grant );

	$params = [
		'client_id'     => $this->clientId,
		'client_secret' => $this->clientSecret,
		'redirect_uri'  => $this->redirectUri,
	];

	if ( ! empty( $this->pkceCode ) ) {
		$params['code_verifier'] = $this->pkceCode;
	}

	$params   = $grant->prepareRequestParameters( $params, $options );
	$request  = $this->getAccessTokenRequest( $params );
	$response = $this->getParsedResponse( $request );

	if ( \is_array( $response ) === false ) {
		throw new UnexpectedValueException(
			'Invalid response received from Authorization Server. Expected JSON.'
		);
	}

	$prepared = $this->prepareAccessTokenResponse( $response );
	$token    = $this->createAccessToken( $prepared, $grant );

	return $token;
}