0

我正在尝试使用新的 sp-api 和混合方法连接到亚马逊。我把模型带到这里并大摇大摆地“编译”它。然后我尝试执行示例代码:

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

4

2 回答 2

1

答案是听到

手工请求专制的详细解释)

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

于 2021-06-20T09:15:49.240 回答