amazon-sp-api: Keep getting Unauthorized using sample requests

Keep getting Unauthorized error using sample requests in docs. Should these examples work?

I’m trying to work out if I’m not authenticating properly or whether the API endpoint is giving the error as I’m trying to request data that I don’t have access to (as it’s your data)

Using a brand new marketplace seller account / no products / data.

CustomError: Access to requested resource is denied.
    at SellingPartner.callAPI (/Users/steven/Documents/boilerplate/versiontwo/node_modules/amazon-sp-api/lib/SellingPartner.js:203:13)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at /Users/steven/Documents/boilerplate/versiontwo/packages/amazon/lib/SP-api.ts:19:19 {
  code: 'Unauthorized',
  details: '',
  type: 'error'
}
require("dotenv").config();
require("source-map-support").install();

import SellingPartnerAPI from "amazon-sp-api";

(async () => {
  try {
    const sellingPartner = new SellingPartnerAPI({
      region: "eu",
      refresh_token:
        "XXX",
      options: {
        auto_request_tokens: true,
        auto_request_throttled: true,
      },
    });

    let res = await sellingPartner.callAPI({
      operation: "createReport",
      body: {
        reportType: "GET_FLAT_FILE_OPEN_LISTINGS_DATA",
        marketplaceIds: ["A1PA6795UKMFR9"],
      },
    });

    console.log(res);
  } catch (e) {
    console.log(e);
  }
})();

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 31 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@Stevenje Awesome! Just tested a few endpoints there and they all seem to be working. I would be really curious to find out what was wrong as Amazon’s end to affect so many people. Thanks a lot for letting me know, much appreciated!

FWIW, I can confirm I was able to use this package in NA using the instructions in the README.