微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

亚马逊 sp-api使用带有 swagger 生成代码的旧 MWS 令牌进行身份验证

如何解决亚马逊 sp-api使用带有 swagger 生成代码的旧 MWS 令牌进行身份验证

我正在尝试使用新的 sp-api 和混合方法连接到 Amazon。我拿了 here 模型并大摇大摆地“编译”它。然后我尝试执行示例代码

from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = swagger_client.AuthorizationApi(swagger_client.apiclient(configuration))
selling_partner_id = 'selling_partner_id_example' # str | The seller ID of the seller for whom you are requesting Selling Partner API authorization. This must be the seller ID of the seller who authorized your application on the Marketplace Appstore.
developer_id = 'developer_id_example' # str | Your developer ID. This must be one of the developer ID values that you provided when you registered your application in Developer Central.
mws_auth_token = 'mws_auth_token_example' # str | The MWS Auth Token that was generated when the seller authorized your application on the Marketplace Appstore.

try:
    # Returns the Login with Amazon (LWA) authorization code for an existing Amazon MWS authorization.
    api_response = api_instance.get_authorization_code(selling_partner_id,developer_id,mws_auth_token)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AuthorizationApi->get_authorization_code: %s\n" % e)

但我收到错误消息:

Exception when calling AuthorizationApi->get_authorization_code: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Date': 'Thu,03 Jun 2021 15:45:52 GMT','Content-Type': 'application/json','Content-Length': '135','Connection': 'keep-alive','x-amzn-RequestId': '6b00b699-2ce1-4973-a155-d7ecee9d7f7b','x-amzn-ErrorType': 'MissingAuthenticationTokenException','x-amz-apigw-id': 'AWvfqFUmoAMF6Yg='})
HTTP response body: {
  "errors": [
    {
      "message": "Access to requested resource is denied.","code": "MissingAuthenticationToken"
    }
  ]
}

有些人说 NEED HEADER 但在文档中却没有。

所以我的问题是: 如何授权,使用 MWS 旧令牌??

解决方法

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。