使用curl连接到Amazon Selling Partner API

问题描述

好的,我必须在问题中添加更多详细信息,所以这是我尝试从我的卖家中央帐户获取订单的方法

Response:403

{
  "errors": [
    {
      "message": "Access to requested resource is denied.","code": "Unauthorized","details": "Access token is missing in the request header."
    }
  ]
}

我使用了以下示例文件https://github.com/avi-wish/aws4-signature-php 不幸的是,没有变量$ host的示例URL

如果我测试连接,这是我的答复:

{{1}}

在这里找到了可能的解决方案:

https://github.com/amzn/selling-partner-api-docs/issues/52#issuecomment-713522351

但这对我不起作用。

是否需要在之前创建IAM用户?这是我创建它的方法
https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#registering-your-selling-partner-api-application

我认为很多人都有同样的问题。希望有人能给我提示

解决方法

不幸的是,您所提供的信息很少。通过grant-type设置的SP-API有两种授权方法。

我想您想授权自己而不是供应商。

然后,您必须将请求发送到以下端点:

api.amazon.com/auth/o2/token

您必须使用api.amazon.com指定$ host。

请求方法将为POST

您将参数传递给http正文: grant_typerefresh_tokenclient_idclient_secret

请查看以下链接:

Connecting to the Selling Partner API

以相同的方式完成所有这些操作后,您将获得以下答案:

{
"access_token":"Atza|IwEBIJR-9fxxxxxxxxxxxxxxxxxxxxxx","refresh_token":"Atzr|IwEBIxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"bearer","expires_in":3600
}

现在,您可以使用access_token签署请求。 在下文中,我还建议您使用其他答案中的信息来签署请求并成功发送请求。

Answer: 64858116