如何解决使用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_type
,refresh_token
,client_id
,client_secret
请查看以下链接:
Connecting to the Selling Partner API
以相同的方式完成所有这些操作后,您将获得以下答案:
{
"access_token":"Atza|IwEBIJR-9fxxxxxxxxxxxxxxxxxxxxxx","refresh_token":"Atzr|IwEBIxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"bearer","expires_in":3600
}
现在,您可以使用access_token签署请求。 在下文中,我还建议您使用其他答案中的信息来签署请求并成功发送请求。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。