亚马逊欧洲MWS Python Boto连接AccessDenied

时间:2016-05-15 03:28:38

标签: python python-3.x boto amazon-mws amazon-marketplace

最近,我开始学习Python。我计划为我们公司制定一个程序来管理来自所有亚马逊商城网站,我们自己的Bigcommerce商店和eBay的订单。

现在,我可以使用Boto库成功向亚马逊美国,亚马逊加拿大和亚马逊墨西哥发送请求,并获取所有订单信息。 (Boto是我能找到的唯一一个与亚马逊MWS完美配合的库)但是当我使用相同的方法向Amazon.co.uk发送请求时,它失败了。以下是我用来发送请求的示例代码。

from boto.mws.connection import MWSConnection
MarketPlaceID = marketplaceid
MerchantID = merchantid
AccessKeyID = accesskeyid
SecretKey = secretkey
mws = MWSConnection(AccessKeyID,SecretKey)
mws.SellerId = MerchantID
mws.Merchant = MerchantID
mws.MarketplaceId = MarketPlaceID
orderstatus = ['PartiallyShipped','Unshipped', 'Shipped']
orders=mws.list_orders(LastUpdatedAfter = '2016-05-01T17:00:00Z', MarketplaceId = [MarketPlaceID],OrderStatus=orderstatus)

此代码适用于我们在亚马逊加拿大,亚马逊美国和亚马逊墨西哥的商店。但是当我将它用于Amazon.co.uk时,我总是得到这些AccessDenied代码。 (我100%确认所有marketplaceid,sellersid,accesskeyid和secretkeyid都是正确的。)

AccessDenied
Traceback (most recent call last):
  File "C:\Python\Amazon Test.py", line 17, in <module>
orders=mws.list_orders(LastUpdatedAfter='2016-05-01T17:00:00Z', MarketplaceId = [MarketPlaceID],OrderStatus=orderstatus)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 158, in requires
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 158, in requires
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 177, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 196, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 177, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 196, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 177, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 139, in wrapper
return func(*args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 81, in wrapper
return func(self, *args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 252, in wrapper
return func(self, request, response, *args, **kw)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 732, in list_orders
return self._post_request(request, kw, response)
  File "C:\Users\Yinghao\AppData\Local\Programs\Python\Python35-32\lib\site-packages\boto\mws\connection.py", line 323, in _post_request
response.reason, body)
boto.mws.response.ResponseFactory.element_factory.<locals>.DynamicElement:         AccessDenied: Unauthorized 
Access denied

有谁能告诉我如何通过Python Boto库或其他Python库发出连接到Amazon.co.uk的请求?任何帮助都将受到重视。

由于

1 个答案:

答案 0 :(得分:2)

我自己想通了。关键是此行的代码https://github.com/boto/boto/blob/develop/boto/mws/connection.py#L269

更改&#39; mws.amazonservices.com&#39;到了&#39; mws-eu.amazonservices.com&#39;,我可以使用上面的代码连接到亚马逊欧洲。所以这个问题都与Amazon亚马逊MWS端点有关。我可以按照本页的说明使用Boto连接到亚马逊日本,中国,印度,欧洲,http://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html