首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法通过Node.js客户端运行销售合作伙伴应用编程接口操作

无法通过Node.js客户端运行销售合作伙伴应用编程接口操作
EN

Stack Overflow用户
提问于 2021-09-06 09:24:29
回答 1查看 109关注 0票数 0

我有以下代码片段:

代码语言:javascript
复制
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)
    }
})()

它的失败如下所示:

代码语言:javascript
复制
{ 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 user、IAM Policy、IAM角色,然后设置了这个Node.js脚本。

我想要获取给定ASIN元数据,但现在它只是以AccessDenied结束。

我该如何解决这个问题呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-19 19:13:09

如果iam用户有sts策略,它可能应该是arn:aws:iam::99999:role/role-name

代码语言:javascript
复制
process.env.AWS_SELLING_PARTNER_ROLE = "arn:aws:iam::99999:role/role-name"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69072192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档