我正在try 获取特定API的访问令牌,下面给出了curl命令:
curl --location --request POST 'https://example.com/oauth/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=abcd' \
--data-urlencode 'client_secret=abc' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=us' \
--data-urlencode 'scope=a' \
--data-urlencode 'password=abc'
我有以下python代码:
url = 'https://example.com/oauth/connect/token'
body = {'client_id':'abcd',
'client_password':'abc',
'grant_type':'password',
'username':'us',
'scope':'a',
'password':'abc'}
headers = {'Content-Type':'application/x-www-form-urlencoded'}
response = requests.post(url, data=body, headers=headers, verify=False)
print(response,response.content)
我一直收到<Response [400]> b'{"error":"invalid_client"}'
个错误.
我相信我已经try 了几乎所有的东西,我迷路了.如果我遗漏了一些非常简单的东西,请告诉我.