沃尔玛API文档链接:
https://developer.walmart.com/home/us-mp/
沃尔玛不同的站点的授权方式是不一致的:
US站点authorzation采用获取access token的方式
获取开发者信息,打开店铺后台,设置,API key Management,记录My API Key对应的
Client ID和 Client Secret 备用

请求头参数内容
链接:https://developer.walmart.com/doc/us/us-mp/us-mp-auth/

WM_SVC.NAME: Walmart Service Name 必填 例如:Walmart Marketplace
WM_QOS.CORRELATION_ID: 每个请求的唯一Id 必填 例如:python的uniqid
WM_CONSUMER.CHANNEL.TYPE :如果凭证是卖家自己用的,这个值为空。如果是第三方服务商调用API,这个值需要第三方服务商从Walmart那里通过商务合作获得,这个参数是用于Walmart识别是哪个第三方在调用API的
Authorization: 用Client ID and Client Secret组合生成的
WM_SEC.ACCESS_TOKEN :必填,通过用Client ID and Client Secret 请求Token API 获取的access_token,有效期为15分钟
获取授权Authorization(直接上代码)
authorization = 'Basic ' + base64.b64encode(bytes(self.client_id + ':' + self.client_secret,encoding='utf8')).decode()
获取access token
url = 'https://marketplace.walmartapis.com/v3/token?'
authorization = 'Basic ' + base64.b64encode(bytes(self.client_id + ':' + self.client_secret,encoding='utf8')).decode()
headers = {
'Authorization': authorization,
'Content-Type': 'application/x-www-form-urlencoded',
'accept': 'application/json',
'WM_CONSUMER.CHANNEL.TYPE': '',
'WM_QOS.CORRELATION_ID': pyuniqid.uniqid(), # TODO 此处只是类型问题
'WM_SVC.NAME': 'Walmart Marketplace'
}
data = {'grant_type': 'client_credentials'}
response = requests.post(url=url, headers=headers, data=data)
即可请求订单数据
欢迎留言和评论😃😃😃