0

我有 .NET 应用程序,它成功地从 Amazon Selling Partner API Orders API 查询信息(执行那些不需要受限数据令牌 RDT 的请求)。但是,当我尝试使用相同的 LWA 令牌和用户令牌并请求签名代码来发出报告 API 请求时,我得到了 Amazon 响应:

拒绝访问请求的资源。未经授权

我的问题是 - Reports API 是否需要一些额外的角色、权限或其他配置,而不是 Orders API 的客户端所拥有的权限?例如,Token API 需要在应用开发者资料中请求额外的权限。

我的亚马逊用户的当前政策是:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "execute-api:Invoke",
            "Resource": "arn:aws:execute-api:*:*:*"
        }
    ]
}

Reports API 的代码是(没有详细说明某些程序的实现):

Model.ReportOptions reportOptions = new Model.ReportOptions();
            DateTime fromDate = new DateTime(2021, 1, 1);
            DateTime toDate = new DateTime(2021, 12, 31);
            List<string> marketplaceIds = new List<string>();
            marketplaceIds.Add(marketplace_id);
            Model.CreateReportSpecification spec = new Model.CreateReportSpecification(
                reportOptions, "GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL", fromDate, toDate, marketplaceIds
                );
            IRestRequest restRequest = new RestRequest(create_report_resource, Method.PUT);

            String postBody = SerializeBody(spec);
            restRequest.AddParameter("application/json", postBody, ParameterType.RequestBody);

            restRequest = SignWithAccessToken(restRequest, credentials.LWA_App_ClientId, credentials.LWA_App_ClientSecret, credentials.RefreshToken);
            restRequest = justSign(restRequest, restClient.BaseUrl.Host, credentials.UserARN, credentials.AWSKey, credentials.AWSSecret);

            System.Net.ServicePointManager.SecurityProtocol =
                System.Net.SecurityProtocolType.Tls12 |
                System.Net.SecurityProtocolType.Tls11 |
                System.Net.SecurityProtocolType.Tls;
            IRestResponse response = restClient.Execute(restRequest);

https://github.com/amzn/ selling-partner-api-docs/issues/52 表示亚马逊在 2020 年底邀请与用户支持私下讨论此类情况。但现在(2021.12)销售合作伙伴 API应该足够健壮...

4

0 回答 0