如何使用 python 請求模塊在 API 呼叫中傳遞不記名令牌?下面我嘗試過:
import requests
import json
api_url = " "# url
todo = "" #Data to send
headers = {"Content-Type":"application/json"} # how to pass bearer token
response = requests.post(api_url, data=json.dumps(todo), headers=headers)
print(response.json())
uj5u.com熱心網友回復:
在之前定義令牌并將標題更改為:
headers = {"Content-Type":"application/json", "Authorization": f"Bearer {token}"}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/421241.html
標籤:
