WC_API_Authentication::exit_with_unauthorized_headers()
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.
Method of the class: WC_API_Authentication{}
No Hooks.
Return
null
. Nothing.
Usage
// private - for code of main (parent) class only $result = $this->exit_with_unauthorized_headers();
Changelog
Since 2.4 | Introduced. |
WC_API_Authentication::exit_with_unauthorized_headers() WC API Authentication::exit with unauthorized headers code WC 7.7.0
private function exit_with_unauthorized_headers() { $auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'woocommerce' ); header( 'WWW-Authenticate: Basic realm="' . $auth_message . '"' ); header( 'HTTP/1.0 401 Unauthorized' ); throw new Exception( __( 'Consumer Secret is invalid.', 'woocommerce' ), 401 ); }