簡體   English   中英

使用python請求克隆curl

[英]Clone curl with python-requests

此curl請求有效:

curl -H 'content-type: application/json' --inient_id":"?CLIENT_ID??", "client_secret":"CLIENT_SECRET", "grant_type":"client_credentials", "scope": "anonymous"}' https://auth2do2go.fitdev.ru/oauth/token

此python請求不會:

data = {
    "client_id": "CLIENT_ID", 
    "client_secret": "CLIENT_SECRET",
    "grant_type": "client_credentials", "scope": "anonymous"
}

url = "https://auth2do2go.fitdev.ru/oauth/token/"
headers = {'content-type': 'application/json'}
r = requests.get(url, headers=headers, data=data, verify=False)
print(r.content)

為什么會這樣呢?

我已經嘗試過data = json.dumps(data)而不是data = data,仍然沒有運氣。

您的數據不是JSON:

import json
r = requests.get(url, headers=headers, data=json.dumps(data), verify=False)

另外,請勿在此處發布實時憑據;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM