“缺少身份验证令牌”调用 Amazon SP-API 时的响应
我试图从AMZ SP-API获得成功的回应。以下是我目前的400响应。
我相信问题是标题。 docs 并没有真正说明标题内容需要什么。
当我使用salewever软件包在这里,我能够成功地打电话使用我的AWS和卖方凭证,所以我知道这些工作...
FWIW,我将“商人令牌”用作“ sellerid”路径价值。
import requests
import json
headers = {
'x-amz-access-token': access,
'client_id': clientid,
'client_secret':secret,
'x-amz-date' : '20220402'
}
payload = {'marketplaceId':'ATVPDKIKX0DER'}
sellerId = merch_token
sku = sku
response = requests.get(
f'https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/{sellerId}/{sku}',
headers = headers,
params = payload
)
print(response.text)
回复:
{
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "MissingAuthenticationToken"
}
]
}
I am attempting to get a successful response from the AMZ SP-API. Below is my current 400 response.
I believe the issue is with the headers. The docs here don't really state what the header contents needs to be.
When I use the SaleWeaver package here, I am able to successfully make calls using my AWS and Seller credentials, so I know these work...
FWIW, I am using my 'Merchant Token' as the 'sellerID' PATH value.
import requests
import json
headers = {
'x-amz-access-token': access,
'client_id': clientid,
'client_secret':secret,
'x-amz-date' : '20220402'
}
payload = {'marketplaceId':'ATVPDKIKX0DER'}
sellerId = merch_token
sku = sku
response = requests.get(
f'https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/{sellerId}/{sku}',
headers = headers,
params = payload
)
print(response.text)
response:
{
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "MissingAuthenticationToken"
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标头有 4 个字段,无需签名:
如果您使用 AWS SDK,则 不需要 签署您的请求。在您的情况下,您必须添加 Authentication 标头(这就是它现在显示缺少令牌的原因)。使用 Auth 标头,请求看起来类似于
您可以阅读有关如何计算签名以及如何添加 auth 标头的更多信息 此处。
The header has 4 fields without signing:
If you use AWS SDK, you don't need to sign your requests. In your case, you'll have to add an Authentication header (which is why it shows missing token right now). With the Auth header, the request looks something like
You can read up more on how to calculate the signature and how to add the auth header here.