I am making a POST request to a URL using 'httpx' library. However, I get a 401 unauthorized error with my below request
cert = os.path.realpath('./certs/certificate.pem')
key = os.path.realpath('./certs/key.pem')
context = ssl.create_default_context()
context.load_cert_chain(certfile=cert, keyfile=key, password=os.getenv('PASSWORD', ''))
response = httpx.post(
url=my_url,
data={'client_id': os.getenv('USER', '')},
verify=context
)
token = response.json()['access_token']
In contrast, if I make the same request using 'requests' library, then it succeeds and I get the response. Below is my request
cert = os.path.realpath('./certs/certificate.pem')
key = os.path.realpath('./certs/key2.pem')
certificate = (cert, key)
response = requests.post(my_url, cert=certificate, auth=HTTPBasicAuth(os.getenv('USER', ''), os.getenv('PASSWORD', '')))
token = response.json()['access_token']
May I know what am I missing here?