bhushankummar / amazon-mws

Amazon MWS NodeJS Wrapper
MIT License
197 stars 78 forks source link

Access denied #61

Closed Raidus closed 6 years ago

Raidus commented 6 years ago

Hi,

I'm always getting access denied although the credentials are correct since I've tested the same credentials with https://github.com/beardon/mws-api and the MWS Scratchpad

My Code:

const { MWS } = require("../config/dev.js");

const account = "XXXXXX"
const amazonMws = new MwsApi();

amazonMws.setApiKey(
  process.env.AWS_ACCESS_KEY_ID,
  process.env.AWS_SECRET_ACCESS_KEY
);

amazonMws.orders.search(
  {
    Version: "2013-09-01",
    Action: "ListOrders",
    SellerId: MWS.merchantId[account], //"SELLER_ID",
    MWSAuthToken: MWS.authToken, //"MWS_AUTH_TOKEN",
    "MarketplaceId.Id.1": MWS.MarketplaceId.de, //"MARKET_PLEACE_ID_1",
    LastUpdatedAfter: new Date(2018, 09, 24)
  },
  function(error, response) {
    if (error) {
      console.log("error ", error);
      return;
    }
    console.log("response", response);
  }
);
error products { Type: 'Sender',
  Code: 'AccessDenied',
  Message: 'Access denied',
  Headers:
   { 'x-mws-quota-max': 'unknown',
     'x-mws-quota-remaining': 'unknown',
     'x-mws-quota-resetson': 'unknown',
     'x-mws-timestamp': '2018-10-06T14:09:38.212Z',
     'content-type': 'text/xml',
     'content-charset': 'unknown',
     'content-length': '294',
     'content-md5': 'unknown',
     date: 'Sat, 06 Oct 2018 14:09:38 GMT' },
  StatusCode: 401,
  RequestId: '4ef544f5-810c-4a98-8654-2682f131b007' }
bhushankummar commented 6 years ago

@Raidus Possibly your AccessKey and SecretKey are wrong.

Raidus commented 6 years ago

@bhushankumarl thanks for you feedback but as I've told you, I've tested the same credentials (AccessKey and SecretKey) with another module and with the MWS Scratchpad. Both worked.

Raidus commented 6 years ago

solution was setting the correct marketplace:

amazonMws.setHost("mws.amazonservices.de");
wangjue666 commented 5 years ago

solution was setting the correct marketplace:


amazonMws.setHost("mws.amazonservices.de");
``wow it is so niiiiiiiiiiiice`