I have the following snippet:
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)
}
})()
This fails like this:
{ code: 'AccessDenied',
message:
'User: arn:aws:iam::7xxxx9:user/XXX is not authorized to
perform: sts:AssumeRole on resource: SellingPartnerAPIRole',
type: 'error' }
I do not understand why it is failing, because I simply followed the official docs to create the IAM user, the IAM Policy, the IAM Role and then setup this Node.js script.
I want to get the metadata for a given ASIN, but for now it simply ends with AccessDenied
.
How can I solve this?
It should probably be arn:aws:iam::99999:role/role-name
if the iam user has sts policy.(not user ARN)
process.env.AWS_SELLING_PARTNER_ROLE = "arn:aws:iam::99999:role/role-name"