我正在尝试打出Walmart api的请求,并按照文档中所述获取auth令牌:
https://developer.walmart.com/#/apicenter/marketPlace/latest#apiAuthentication
这是我的代码:
import base64
import requests
import json
url = "https://marketplace.walmartapis.com/v3/token"
clientId = ""
clientSecret = ""
auth = clientId+":"+clientSecret
encoded = base64.b64encode(bytes(auth.encode()))
headers = {
"Authorization": encoded,
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
"WM_SVC.NAME": "Walmart Marketplace",
"WM_QOS.CORRELATION_ID": "123456abcdef",
"WM_SVC.VERSION": "1.0.0"
}
body ={"grant_type":"client_credentials"}
response=requests.post(url, headers=headers, data=json.dumps(body))
print(response)
我得到:
b'{"error":[{"code":"SYSTEM_ERROR.GMP_GATEWAY_API","info":"System encountered some internal error.","severity":"ERROR","category":"DATA","causes":[],"errorIdentifiers":{}}]}'
我不确定我做错了什么。