【发布时间】:2022-06-21 21:00:35
【问题描述】:
我正在尝试发出一个简单的请求以从 Citrix ShareFile 获取访问令牌,但它会引发 400 错误。
我将完全按照文档中的说明进行操作,除了使用 HTTPLib 更改 Python2 代码,使用 Requests 更改 Python3 代码。代码是:
url = 'https://{my_domain}.sharefile.com/oauth/token'
headers = {'Content_Type': 'application/x-www-form-urlencoded'}
params = {'grant_type':'password', 'client_id':my_client_id, 'client_secret':my_client_secret, 'username':my_username, 'password':my_password}
response = requests.post(url, params=params, headers = headers)
print(response.status_code, response.reason)
我收到以下回复:
400 Bad Request
我还在参数中添加了 urllib.parse.urlencode,但仍然收到相同的响应错误
response = requests.post(url, params=urllib.parse.urlencode(params), headers = headers)
请求有关我做错了什么的指导。 TIA
【问题讨论】:
标签: python python-requests citrix sharefile