In this blog, we will learn how to send webservice key in the authorization header instead of the URL.
Sometimes we need that we do not want to show webservice key in the API URL & Prestashop sends ws_key with its value in the URL. Check this:

If we want to remove this from the URL, we need to send this in the authorization header as Basic Auth. Please check the below image.

Also, there is another option to manage webservice key privacy. You can set this ws_key directly in the code to manage APIs.
For this, You need to save webservice key in a configuration key & then you can directly access this ws_key.
$wsKey = Configuration::get('YOUR_WEBSERVICE_KEY');
You can directly set ws_key in webservice dispatcher.php
$wsKey = Configuration::get('YOUR_WEBSERVICE_KEY'); $_GET['ws_key'] = $wsKey;
Here is the file path: YOUR_PRESTASHOP_ROOT/webservice/dispatcher.php
Now you can check there is no authentication set for webservice request & no ws_key pass in the API URL but the result is still present.

That’s all about this blog. Hope it will help you.
If you are facing any issues or have any doubts about the above process, please feel free to contact us through the comment section.
Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.
For any doubt contact us at [email protected]
Be the first to comment.