我必须在
Python中发出HTTPS请求,并且我正在使用请求模块来尝试让我的生活更轻松.
请求需要有一个标头和3个FORM参数URL编码.这就是我在做的事情:
header = {'Content-type': 'application/x-www-form-urlencoded', 'Authorization':'Basic ' + encoded_string, 'Connection': 'Keep-Alive', 'Host':'host.host.com'}
payload='grant_type=authorization_code&code=' + request.args['code'] + '&state=' + request.args['state'] + '&redirect_uri=http://xxx.xyz.com/request_listener'
url = 'https://serviceprovider.xxx.com/auth/j_oauth_resolve_access_code'
response = requests.post(url, data=payload, headers=header, verify=False)
当我尝试返回响应的内容或文本时,我得到一个空字符串.但是,当我打印实际响应对象时,它表示它是< Response [200]>,但如果这实际上是200 OK,那么我发布的服务器也应该转到我指定的redirect_uri,我会在那里得到通知.
这种情况没有发生,我为什么感到困惑.