当我使用htaccess时连接到Prestashop API

问题描述 投票:0回答:1

我正在尝试访问 Prestashop 的 API,但我的 prestashop 受 .htaccess 保护。
通过阅读 prestashop docs

prestashop使用与.htaccess相同的基本身份验证的问题。

我尝试了这个网址:

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

带有 HTTP 标头

Authorization : Basic <apikey>

错误响应如下:

<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>

您有实现 .htaccess 身份验证和 api 密钥的想法吗? PS:我使用的是最新版本的Prestashop 1.7

.htaccess prestashop-1.7
1个回答
0
投票

您可以将 API 密钥作为 GET 参数发送,同时保留 .htaccess 基本身份验证:

https://www.example.com/api?ws_key=XXXXXXXXXXXXXXXXXXXXXXX
© www.soinside.com 2019 - 2024. All rights reserved.