/** * Set authentication parameters for the request * * @since 2.0 * @param string $consumer_key API consumer key * @param string $consumer_secret API consumer secret * @return string request URL with authentication parameters added */ protected function get_url_with_auth($consumer_key, $consumer_secret) { $auth = new WC_API_Client_Authentication($this->request->url, $consumer_key, $consumer_secret); if ($auth->is_ssl()) { // query string authentication over SSL works with all servers, whereas HTTP basic auth fails in certain cases // see https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/29 $this->request->params = array_merge($this->request->params, array('consumer_key' => $auth->get_consumer_key(), 'consumer_secret' => $auth->get_consumer_secret())); } else { $this->request->params = array_merge($this->request->params, $auth->get_oauth_params($this->request->params, $this->request->method)); } // build url return $this->request->url . (!empty($this->request->params) ? '?' . http_build_query($this->request->params) : ''); }