Boto Making Request on Behalf of Someone Else

Viewed 155

I have an account which I registered as an amazon developer. (Let's call this the developer account)

I have another account which I am treating as the seller account (also an amazon developer account). (Let's call this seller account)

I want my developer account to make requests to amazon on behalf of the seller.

So seller calls my developer app, which talks to Amazon.

According to the terms and conditions, I must use the developer's access and secret key.

I have given my seller the developer ID and I have a Seller Id, Marketplace Id, and a MWS Auth Token.

However, I'm not sure how to get a MWSConnection working since it appears boto doesn't have a parameter for entering the MWS Auth Token

I have tried.

access_key_id = developer_access_key_id
secret_key = developer_secret_key
seller_id = seller_id
MWSConnection(access_key_id, secret_key, SellerId=seller_id)

This results in a failure of AccessDenied

Is there a way to get this working, where I (the developer) can make a request on behalf of someone else (the seller)?

1 Answers

Some things that may not be your problem, but might be

A couple of stabs at what may be your problems before a more explicit solution:

  1. boto3 doesn't support MWS. If you're using it, it will not work. Use boto
  2. MWS in regions that are not North America (NA) require additional configuration that you may not be providing

What your problem probably is...

You're coming in and trying to set the SellerID in the args of MWS with:

MWSConnection(access_key_id, secret_key, SellerId=seller_id)

You should probably be doing it like this instead:

from boto import mws

from boto.mws.connection import MWSConnection
accessKey = developer_access_key_id # Python prefers camelCase
secretKey = developer_secret_key    # Python prefers camelCase
merchantID = "XXXXXXXXXX"           # You never specified this

mws = MWSConnection(accessKey, secretKey)
mws.Merchant = merchantID
mws.SellerId = merchantID

While it is possible to pass in the SellerId through a keyword argument I believe that you have to specify all the named arguments unless you know what their explicit order is.

Arguments to a python function are essentially a dictionary and python just does some convenience for you to line up the order of invocation with the order of declaration. That's why you can be explicit and use argumentName = argumentValue, ... in any order in the invocation and still have your function work.

Related