WC_REST_Authentication::send_unauthorized_headers()publicWC 1.0

If the consumer_key and consumer_secret $_GET parameters are NOT provided and the Basic auth headers are either not present or the consumer secret does not match the consumer key provided, then return the correct Basic headers and an error message.

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

Хуков нет.




$WC_REST_Authentication = new WC_REST_Authentication();
$WC_REST_Authentication->send_unauthorized_headers( $response );
$response(WP_REST_Response) (обязательный)
Current response being served.

Код WC_REST_Authentication::send_unauthorized_headers() WC 7.1.0

public function send_unauthorized_headers( $response ) {
	if ( is_wp_error( $this->get_error() ) && 'basic_auth' === $this->auth_method ) {
		$auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'woocommerce' );
		$response->header( 'WWW-Authenticate', 'Basic realm="' . $auth_message . '"', true );

	return $response;