[英]Amazon SP-API Python SellingApiForbiddenException: Access to requested resource is denied
我知道这个问题被问了很多,但没有一个解决方案对我的情况有帮助。
我在我的亚马逊卖家账户中注册为亚马逊开发人员,现在尝试使用 python-amazon-sp-api 库连接这是我的代码:
from sp_api.api import Orders
import datetime
import json
from datetime import timedelta
from sp_api.base import SellingApiException, Marketplaces
credentials=dict(
refresh_token='***************', # refresh token from authorized from the app on Seller central
lwa_app_id='****************', # lwa id of the app
lwa_client_secret='***************', # lwa secret of the app
aws_secret_key='************', # secret key of IAM user
aws_access_key='************', # access key of IAM user
role_arn='arn:aws:iam::577******:role/SPAPIRole' # IAM role arn
)
print(json.dumps(credentials))
from sp_api.api import Orders, Finances, ProductFees
from sp_api.base import SellingApiException, Marketplaces, SellingApiForbiddenException
import datetime
from datetime import timedelta, date
import time
import csv
marketplaces = ['A2EUQ1WTGCTBG2']
res = Orders(credentials=credentials, marketplace=Marketplaces.CA)
data = res.get_orders(CreatedAfter='2017-03-30',CreatedBefore=date.today().isoformat(),MarketplaceIds=marketplaces)
这是附加给我的用户的策略(不是内联,而是直接作为托管策略附加):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::577951966674:role/SPAPIRole"
}
]
}
我完全遵循了 API 文档,但它不起作用,上面的政策是我试图从我在论坛中阅读的内容中添加的内容。
在开发人员中心(应用程序的 IAM ARN 部分)中添加应用程序时,我尝试同时使用 IAM USER ARN 和 ROLE ARN
我究竟做错了什么?
尝试将 IAM ARN 信息替换为 aws ROLE ARN。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.