403 错误

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

我已经严格按照官方开发人员指南(https://github.com/amzn/ sell-partner-api-docs)进行操作,并且已经能够获取访问和刷新令牌。我还设法使用 SHA256 哈希算法正确签署每个请求。但在尝试进行 API 调用后,这就是我收到的错误。

{
  "errors": [
    {
      "message": "Access to requested resource is denied.",
     "code": "Unauthorized",
     "details": ""
    }
  ]
}

附加到 IAM 角色的内联策略是:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "arn:aws:iam::310069193681:role/SellingPartner"
        }
    ]
}

下面附有其他请求详细信息....

{
  'Date': 'Mon, 12 Jul 2021 10:23:12 GMT', 
   'Content-Type': 'application/json', 
  'Content-Length': '141', 
  'Connection': 'keep-alive', 
  'x-amzn-RequestId': '8541dac4-e734-486b-820d-3010f447b055', 
  'x-amzn-ErrorType': 'AccessDeniedException', 
  'x-amz-apigw-id': 'CWiykGXFDoEF2Xw='
}
python amazon-web-services amazon-selling-partner-api
2个回答
1
投票

我遇到了类似的问题,对我来说,我没有给出应用程序所需的角色。

为了让您的应用程序访问给定资源,您必须选择一些角色。为此,如果您使用新界面:

  1. 转到列出您的应用程序的页面
  2. 选择您的应用程序 -> 编辑
  3. 选择您需要的角色。您可以在
  4. 中检查哪些角色是必需的

https://github.com/amzn/elling-partner-api-docs/blob/main/guides/en-US/roles/Roles-in-the-Selling-Partner-API.md 某些角色受到限制 - 如果是您的情况,您可能需要更新您的开发者资料才能请求它们。


0
投票

我在 Node.js 应用程序中也遇到了同样的错误(使用 amazon-api-api 包)。尽管及时轮换 LWA 凭证并通过 Postman 成功获取信息,我还是收到了以下错误:

{
  "errors": [
    {
      "message": "Access to requested resource is denied.",
      "code": "Unauthorized",
      "details": ""
    }
  ]
}

经过一番调查,我发现问题出在端点版本上。默认情况下,当您连接到 Amazon SP-API 而不指定终端节点版本时,它默认为最旧的版本(例如 2020)。

要解决此问题,您需要在进行 API 调用时指定正确的端点版本。以下是如何操作的示例:

let sellingPartner = new SellingPartnerAPI({
    region: config.region, // The region to use for the SP-API endpoints ("eu", "na" or "fe")
    refresh_token: config.refresh_token, // The refresh token of your app user
    endpoints_versions: {
      reports: '2021-06-30' // Specify the correct endpoint version
    }
});

通过正确设置端点_版本,我能够成功验证并访问请求的资源。

© www.soinside.com 2019 - 2024. All rights reserved.