无法通过 Node.js 客户 运行 销售合作伙伴 API 操作
Cannot run Selling Partner API operations through the Node.js client
我有以下片段:
const SellingPartnerAPI = require('amazon-sp-api');
process.env.SELLING_PARTNER_APP_CLIENT_ID = "..."
process.env.SELLING_PARTNER_APP_CLIENT_SECRET = "..."
process.env.AWS_ACCESS_KEY_ID = "..."
process.env.AWS_SECRET_ACCESS_KEY = "..."
process.env.AWS_SELLING_PARTNER_ROLE = "SellingPartnerAPIRole"
const TOKEN = '...';
(async () => {
try {
let sellingPartner = new SellingPartnerAPI({
region: "eu",
refresh_token: TOKEN
});
let res = await sellingPartner.callAPI({
operation:'getCompetitivePricing',
endpoint:'productPricing'
});
console.log(res);
} catch (e) {
console.error(e)
}
})()
这样失败了:
{ code: 'AccessDenied',
message:
'User: arn:aws:iam::7xxxx9:user/XXX is not authorized to
perform: sts:AssumeRole on resource: SellingPartnerAPIRole',
type: 'error' }
我不明白为什么会失败,因为我只是按照 official docs 创建 IAM 用户、IAM 策略、IAM 角色,然后设置此 Node.js 脚本。
我想获取给定 ASIN 的元数据,但现在它只是以 AccessDenied
结尾。
我该如何解决这个问题?
如果 iam 用户有 sts 策略,它可能应该是 arn:aws:iam::99999:role/role-name
。(不是用户 ARN)
process.env.AWS_SELLING_PARTNER_ROLE = "arn:aws:iam::99999:role/role-name"
我有以下片段:
const SellingPartnerAPI = require('amazon-sp-api');
process.env.SELLING_PARTNER_APP_CLIENT_ID = "..."
process.env.SELLING_PARTNER_APP_CLIENT_SECRET = "..."
process.env.AWS_ACCESS_KEY_ID = "..."
process.env.AWS_SECRET_ACCESS_KEY = "..."
process.env.AWS_SELLING_PARTNER_ROLE = "SellingPartnerAPIRole"
const TOKEN = '...';
(async () => {
try {
let sellingPartner = new SellingPartnerAPI({
region: "eu",
refresh_token: TOKEN
});
let res = await sellingPartner.callAPI({
operation:'getCompetitivePricing',
endpoint:'productPricing'
});
console.log(res);
} catch (e) {
console.error(e)
}
})()
这样失败了:
{ code: 'AccessDenied',
message:
'User: arn:aws:iam::7xxxx9:user/XXX is not authorized to
perform: sts:AssumeRole on resource: SellingPartnerAPIRole',
type: 'error' }
我不明白为什么会失败,因为我只是按照 official docs 创建 IAM 用户、IAM 策略、IAM 角色,然后设置此 Node.js 脚本。
我想获取给定 ASIN 的元数据,但现在它只是以 AccessDenied
结尾。
我该如何解决这个问题?
如果 iam 用户有 sts 策略,它可能应该是 arn:aws:iam::99999:role/role-name
。(不是用户 ARN)
process.env.AWS_SELLING_PARTNER_ROLE = "arn:aws:iam::99999:role/role-name"