如何使用Python请求执行NTLM SSPI身份验证? [英] How to use Python requests to perform NTLM SSPI authentication?

查看:550
本文介绍了如何使用Python请求执行NTLM SSPI身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是通过带有SSPI的NTLM对使用Python 3.5.2中的请求库(2.11.1)的客户端进行身份验证,以便用户不必手动输入域凭据(用于登录PC)

我发现了以下可能性,但对我没有用:

  • HttpNtlmSspiAuth 在请求中引发异常:

    导入请求 从request_ntlm导入HttpNtlmAuth,HttpNtlmSspiAuth

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




我做错什么了吗?

解决方案

requests-negotiate -sspi 为我工作.

我可能对PO也有同样的问题,但是我懒得尝试PO的解决方案并将PO的代码集成到我的代码中.谷歌帮助了我.万一有人遇到sspi.py ValueError: year 30828 is out of range引发的相同异常,这是 requests-negotiate-sspi .参见此处: Github问题

我通过使用python 3.4创建新的conda环境解决了这一问题.然后重新安装一些依赖项以及requests-negotiate-sspi,boom,一切正常.

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?

解决方案

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.

这篇关于如何使用Python请求执行NTLM SSPI身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆