Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomError: Access to requested resource is denied. #32

Closed
kevinhq opened this issue Apr 18, 2021 · 2 comments
Closed

CustomError: Access to requested resource is denied. #32

kevinhq opened this issue Apr 18, 2021 · 2 comments

Comments

@kevinhq
Copy link

kevinhq commented Apr 18, 2021

Hi,

Any idea with this error:

CustomError: Access to requested resource is denied.
    at SellingPartner.callAPI (/Users/k/node_modules/amazon-sp-api/lib/SellingPartner.js:503:13)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async /Users/k/Y/Lister/amz-sp-api-node.js:17:15 {
  code: 'Unauthorized',
  details: '',
  type: 'error'
}

Here are the codes we use:

const SellingPartnerAPI = require("amazon-sp-api"); 
  
(async () => {
  try {
    console.log(process.env);
    let sellingPartner = new SellingPartnerAPI({
      region: "na",
      refresh_token: process.env.AMZ_SP_API_REFRESH_TOKEN,
      credentials: {
        SELLING_PARTNER_APP_CLIENT_ID: process.env.SELLING_PARTNER_APP_CLIENT_ID,
        SELLING_PARTNER_APP_CLIENT_SECRET: process.env.SELLING_PARTNER_APP_CLIENT_SECRET,
        AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
        AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,
        AWS_SELLING_PARTNER_ROLE: process.env.AWS_SELLING_PARTNER_ROLE
      },
    });
    let res = await sellingPartner.callAPI({
      operation:'getMarketplaceParticipations'
    });
    console.log(res);
  } catch (e) {
    console.log(e);
  }
})();

We tried other operations too, but all of them return the same error. We can access the MWS API just fine. But, we don't have active Amazon Seller Account (is this an issue?)

@kevinhq kevinhq changed the title Access to requested resource is denied. CustomError: Access to requested resource is denied. Apr 18, 2021
@amz-tools
Copy link
Owner

HI @kevinhq,

could be that one of the config params is wrong (either the token or one of the credentials), but I would rather go with the inactive seller account explanation. It is definitely required to have a professional seller account and I'd guess that requires the account to be active as well.

What is weird though: The same applies to the MWS API, so its strange that you can access MWS if the inactive seller account is the explanation. Guess the easiest way is to open a case with Amazon and ask them directly.

One more thing about the code: If you already provide the credentials as env variables you can skip defining them in the constructor config object.

@kevinhq
Copy link
Author

kevinhq commented Apr 18, 2021

Guess the easiest way is to open a case with Amazon and ask them directly.

We tried but Amazon just close the case with the reason we have no active Amazon seller account. To be honest, the same error goes with the Ruby implementation.

Ok, I'll ask the product owner about activating their Amazon seller account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants