亚马逊 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 旧令牌??

解决方法

我确定什么是 IAM ARN 问题或授权 URL 问题。

https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#step-4-create-an-iam-role

你可以了解状态

https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#step-3-the-selling-partner-signs-into-your-website

,

答案是heare

手工请求专制详解)

当我的代码生效时,我会把它放在这里。