You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Amazon SP-API Orders接口报错:应用无部分/全部请求资源访问权限

解决Selling Partner API调用getOrders时的权限错误问题

调用Orders API的getOrders()/getOrder()方法时,收到错误提示:

Application do not have access to some or all requested resource

代码通过composer require jlevers/selling-partner-api安装依赖,完全参考对应仓库指引完成Selling Partner API连接配置,且调用getMarketplaceParticipations()时无异常,排除基础配置问题,求解决方向。

调用代码

<?php
require_once(__DIR__ . '/vendor/autoload.php');
    
$token = "<TOKEN>";
    
use SellingPartnerApi\Api\SellersV1Api as SellersApi;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\Endpoint;
    
$config = new Configuration([
    "lwaClientId" => "amzn1.applica..",
    "lwaClientSecret" => "<clientSecret>",
    "lwaRefreshToken" => $token,
    "awsAccessKeyId" => "<accessKey>",
    "awsSecretAccessKey" => "<secretAcessKey>",
    "endpoint" => Endpoint::FE
]);
    
$apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config);
$marketplace_ids = array('A1############'); 
$created_after = '2022-07-27';
    
try {
    $result = $apiInstance->getOrders($marketplace_ids);

    print "<pre>";
    print_r($result);
    print "</pre>";
    
} catch (Exception $e) {
    echo 'Exception when calling OrdersV0Api->getOrders: ', $e->getMessage(), PHP_EOL;
}

错误信息

Exception when calling OrdersV0Api->getOrders: [400] { "errors": [ { "code": "InvalidInput", "message": "Application do not have access to some or all requested resource", "details": "" } ] }

排查方向

  • 确认应用权限:登录亚马逊开发者后台,检查SP-API应用是否已申请并获得Orders API(v0版本)的访问权限。若未开通,需提交权限申请并等待审核通过。
  • 验证刷新令牌权限范围:生成刷新令牌时,需确保勾选了Orders API相关权限。如果令牌生成时未包含该权限,即使应用本身有权限,也无法访问Orders资源,需重新生成包含对应权限的刷新令牌。
  • 核对Marketplace ID匹配性:确认传入的marketplace_ids对应的站点,是否与应用已开通权限的站点一致。例如应用仅开通欧洲站权限,但传入北美站ID,会触发权限错误。
  • 检查IAM角色政策:确认AWS IAM角色的政策是否允许访问Orders API的资源路径,确保政策包含execute-api:Invoke权限,且资源范围覆盖Orders API端点。
  • 验证参数格式:确认created_after等参数符合SP-API要求的ISO 8601格式(例如2022-07-27T00:00:00Z),严格符合规范可避免潜在格式类问题。

内容的提问来源于stack exchange,提问作者exceptione

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 13:48:19