I have the following code in shell script that I am trying to convert into Python code using request.post
:
ESCAPED_PASSWORD = 'hfsudfgi88
USERID = 1234
AUTHO_HOST = 'blah.refdata.com'
AUTH_URL = "https://${AUTH_HOST}/as/tok.oauth2"
resp=$(curl --silent "${AUTH_URL}" --request POST \
-H "Host: ${AUTH_HOST}" \
-H "Content-Type: applion/x-www-f-urled" \
-d "grant_type=client_credentials&client_id=${USERID}&client_secret=${ESCAPED_PASSWORD}")
When I run the above, I get back a json dictionary (success!).
This is my python code:
res = {
"grant_type":"client_credentials",
"client_id": USERID,
"client_secret":ESCAPED_PASSWORD
}
# send post request
response = requests.post(AUTH_URL, json=res)`
When I run my Python code however, I get back an error:
socket.gaierror: [Errno -2] Name or service not known