How to use Python requests to perform NTLM SSPI authentication?

16,333

The package requests-negotiate-sspi works for me.

I probably had the same issue with PO, but I was too lazy to try PO's solution and integrate PO's code into mine. And Google helped me out. In case anyone encounters the same exception raised from sspi.py ValueError: year 30828 is out of range, it's a known issue for python 3.6 of requests-negotiate-sspi. See here: Github-Issue

I solved this by creating a new conda environment with python 3.4. Then reinstall some dependencies as well as requests-negotiate-sspi, boom, all works.

Share:
16,333
R01k
Author by

R01k

Updated on June 04, 2022

Comments

  • R01k
    R01k almost 2 years

    My goal is to authenticate my client that uses the requests library (2.11.1) in Python 3.5.2 through NTLM with SSPI so that the user does not have to manually enter her domain credentials (used to login to the PC).

    I have found the following possibilities, but none work for me:

    • HttpNtlmSspiAuth provokes an exception in requests:

      import requests from requests_ntlm import HttpNtlmAuth, HttpNtlmSspiAuth

      requests.get(site_url, auth=HttpNtlmSspiAuth())




    Am I doing something wrong?