简体   繁体   English

使用 Postman 对 Shopware 5 的 REST 请求进行身份验证失败

[英]Authentication fails for REST requests to Shopware 5 using Postman

When making REST requests like GET http://<url-to-shop>/api/articles to my own Shopware 5 instance I always get当向我自己的 Shopware 5 实例发出 GET http://<url-to-shop>/api/articles等 REST 请求时,我总是得到

{
    "success": false,
    "message": "Invalid or missing auth"
}

as a response, even though I provide the correct credentials.作为回应,即使我提供了正确的凭据。

I solved it by going to http://<url-to-shop>/backend then to Settings -> User Administration -> edit User -> enable Api Access.我通过转到http://<url-to-shop>/backend然后转到设置 -> 用户管理 -> 编辑用户 -> 启用 Api 访问来解决它。 Then I have to use the username of the user that I just enabled the API access for and most importantly I have to use the API-Key as the password in postman under the option Basic Auth like so:然后我必须使用我刚刚启用 API 访问的用户的用户名,最重要的是我必须在邮递员中使用API-Key 作为密码,在选项Basic Auth下,如下所示:

在此处输入图片说明

Of course this also works with any other API-testing tool like Paw and others.当然,这也适用于任何其他 API 测试工具,如 Paw 等。 I hope this saves you some time if you are trying to get this to work.如果您正在尝试使其工作,我希望这可以为您节省一些时间。 Nowhere in the official documentation of Shopware 5 does it say that you are supposed to use the Api-Key as the password. Shopware 5 的官方文档中没有任何地方说您应该使用 Api-Key 作为密码。 They only write that the Api-Key is supposed to be "included" in the request: https://developers.shopware.com/developers-guide/rest-api/#basic-settings .他们只写了 Api-Key 应该“包含”在请求中: https : //developers.shopware.com/developers-guide/rest-api/#basic-settings

您必须使用 Config 中定义的 URL,而我没有使用 www。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM