Connect to Prestashop API when i used htaccess

59 views Asked by At

I'am trying to access the API of Prestashop but my prestashop is protected by .htaccess.
By reading the prestashop docs

The problem that prestashop use the basic auth that is the same as .htaccess.

I tried this url :

 https://test:[email protected]/api/categories

With an HTTP Header Authorization : Basic <apikey>

The response with error is the following :

<h1>Unauthorized</h1>
    <p>This server could not verify that you
        are authorized to access the document
        requested. Either you supplied the wrong
        credentials (e.g., bad password), or your
        browser doesn't understand how to supply
        the credentials required.</p>
    <p>Additionally, a 401 Unauthorized
        error was encountered while trying to use an ErrorDocument to handle the request.</p>

Do you have an idea of implement the .htaccess authentification and the api key ? PS: I am using the last version Prestashop 1.7

1

There are 1 answers

3
gennaris On

You can send your API key as a GET parameter while retaining your .htaccess Basic Auth :

https://auth_user:[email protected]/api?ws_key=XXXXXXXXXXXXXXXXXXXXXXX

Where auth_user / auth_pass are your already existing Basic Auth info.