Yoast\WP\SEO\Actions\SEMrush

SEMrush_Login_Action::authenticate()publicYoast 1.0

Authenticates with SEMrush to request the necessary tokens.

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

Хуков нет.

Возвращает

Объект. The response object.

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

$SEMrush_Login_Action = new SEMrush_Login_Action();
$SEMrush_Login_Action->authenticate( $code );
$code(строка) (обязательный)
The authentication code to use to request a token with.

Код SEMrush_Login_Action::authenticate() Yoast 22.3

public function authenticate( $code ) {
	// Code has already been validated at this point. No need to do that again.
	try {
		$tokens = $this->client->request_tokens( $code );

		return (object) [
			'tokens' => $tokens->to_array(),
			'status' => 200,
		];
	} catch ( Authentication_Failed_Exception $e ) {
		return $e->get_response();
	}
}