【问题标题】:Amazon SP-API can't assume role of myself?Amazon SP-API 不能扮演我自己的角色?
【发布时间】:2021-06-22 08:26:08
【问题描述】:

我正在尝试使用 node.js 库连接到 Amazon Selling Partners API (SP-API),但遇到了一个非常奇怪的错误,似乎告诉我我不能担任自己的角色?

CustomError: User: arn:aws:iam::11111:user/bob is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::11111:user/bob

我对 AWS 还很陌生,但我很确定这个针对用户的内联策略应该足以满足我想要做的事情,我什至让它适用于所有资源,而不仅仅是 SellingPartners我之前创建的角色:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "*"
        }
    ]
}

这是我的完整代码,以防有帮助:

const SellingPartnerAPI = require('amazon-sp-api');
    
    (async() => {
    try {
        let sellingPartner = new SellingPartnerAPI({
            region:'na', // The region to use for the SP-API endpoints ("eu", "na" or "fe")
            refresh_token:'xxxxxx', // The refresh token of your app user
            credentials:{
                SELLING_PARTNER_APP_CLIENT_ID:'xxxxx',
                SELLING_PARTNER_APP_CLIENT_SECRET:'xxxxx',
                AWS_ACCESS_KEY_ID:'xxxx',
                AWS_SECRET_ACCESS_KEY:'xxxxx',
                AWS_SELLING_PARTNER_ROLE:'arn:aws:iam::11111:user/bob'
            }
        });
        let res = await sellingPartner.callAPI({
            operation:'getOrders',
            endpoint:'orders'
        });
        console.log(res);
    } catch(e) {
        console.log(e);
    }
})();

【问题讨论】:

  • ARN arn:aws:iam::11111:user/bob 描述的是用户而非角色。它可能应该类似于arn:aws:iam::11111:role/your-role-name
  • @Maurice 谢谢,很确定就是这样,因为我现在收到了不同的错误消息(CustomError: Access to requested resource is denied)。如果您将其写为答案,很高兴将其标记为正确!您是否有想法从哪里开始查找新错误?我一直严格按照这些说明github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/…
  • 我已经添加了答案。新的错误消息非常模糊,我没有使用 Selling Partner API,所以很遗憾没有线索。如果您能获得比消息更详细的信息,您可以提出一个新问题。

标签: node.js amazon-web-services amazon-iam amz-sp-api


【解决方案1】:

ARN arn:aws:iam::11111:user/bob 描述的是用户而不是角色

如果客户端需要一个角色 ARN,它可能应该类似于 arn:aws:iam::11111:role/your-role-name

【讨论】:

    猜你喜欢
    • 2020-01-25
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 2021-04-27
    • 2017-06-12
    • 1970-01-01
    相关资源
    最近更新 更多