我正试图从服务器获取acceses令牌oauth2,但响应总是说凭据不正确
headers = {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
'grant_type': 'client_credentials',
}
url = "http://172.15.39.95:8080/oauth/token"
params = {"grant_type": "password", "username": "xxxxx", "password": "xxxxxx"}
client_auth = requests.auth.HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)
x = requests.get(url, params=params, auth=client_auth, headers=headers)
任何帮助都将不胜感激
我想您想使用资源所有者密码凭据授予。请求方法应该是POST,而不是GET(如果我正确地阅读了python代码)。请参见OAuth2 RFC中的示例。 我希望服务器返回“http405methodnotallowed”错误。在
您可能应该删除
grant_type: client_credentials
头,将grant_type
指定为参数,其正确值为password
。在很难说“坏凭证”是什么意思,因为您没有使用POST-request方法。当你改变它时,你应该得到更具体的回应。如果您的基本身份验证客户机标识+客户机密码无效,您应该获得
如果您的
^{pr2}$username
+password
参数无效,您应该得到有关更多错误代码,请参阅OAuth2 RFC。在
相关问题 更多 >
编程相关推荐