I have to make an HTTPS request in Python, and I am using the requests module to try to make my life easier.
The request needs to have a header and 3 FORM parameters URL encoded. This is what I am doing:
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)
When I try to return the content
or text
of the response
, I get an empty string. However, when I print the actual response
object, it says it is a <Response [200]>
, but if this were actually a 200 OK then the server I am POSTing too should go to the redirect_uri I have specified and I would get a notification there.
This is not happening, and I am mystified as to why.