0
我試圖用django發送一個請求,以使用OAuth2從我的api獲取access_token。我執行此代碼:Django OAuth2 unsupported_grant_type
data = {'username': 'admin', 'password': '123123', 'grant_type':
'password','client_id': 'xxx','client_secret': 'xxx'}
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = requests.post(url, data=data, headers=headers)
當我把這一請求,我得到這個錯誤:
{ '錯誤': 'unsupported_grant_type'}
感謝您的幫助!
感謝這個答案。我正在使用application/json作爲內容類型。切換到x-www-form-urlencoded是我需要更改以使其適用於client_credentials授權類型。 –