gpt4 book ai didi

python - 亚马逊欧洲 MWS Python Boto 连接访问被拒绝

转载 作者:太空宇宙 更新时间:2023-11-04 03:13:18 26 4
gpt4 key购买 nike

最近,我开始学习Python。我计划为我们公司构建一个程序来管理来自所有 Amazon Marketplace 网站、我们自己的 Bigcommerce 商店和 eBay 的订单。

现在我可以使用 Boto 库成功地向亚马逊美国、亚马逊加拿大和亚马逊墨西哥发送请求并获取所有订单信息。 (Boto 是我能找到的唯一与 Amazon 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 的请求?任何帮助将不胜感激。

谢谢

最佳答案

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

将“mws.amazonservices.com”更改为“mws-eu.amazonservices.com”后,我可以使用上面的代码连接到亚马逊欧洲。所以这个问题是关于亚马逊 Amazon MWS 端点的。我可以按照此页面的说明使用 Boto 连接到亚马逊日本、中国、印度、欧洲,http://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html

关于python - 亚马逊欧洲 MWS Python Boto 连接访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37234242/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com