I'd like to replicate the following curl command in Python.
curl -u : --negotiate -k https://example.com/authenticate
I followed this pycurl example here and it worked fine http://www.deplication.net/2014/02/curl-with-kerberos-authentication.html
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_GSSNEGOTIATE)
curl.setopt(pycurl.USERPWD, ':')
curl.setopt(pycurl.URL, 'https://example.com/authenticate'
curl.perform()
Is there a way to do it with Python requests module?
Thanks!!
You can try this project: https://pypi.org/project/requests-negotiate/, or if you're using Kerberos: https://pypi.org/project/requests-kerberos/
With either, your code will look something like this:
auth = HTTPNegotiateAuth() # or: HTTPKerberosAuth()
response = requests.get('https://example.com/authenticate', auth=auth, verify=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With