使用Windows身份验证访问Python中的Sharepoint网站 [英] Accessing sharepoint site in python with windows authentication

查看:126
本文介绍了使用Windows身份验证访问Python中的Sharepoint网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Windows身份验证的Sharepoint网站.我可以使用requests模块访问该站点,但需要我明确声明Windows密码.

I am trying to work with a sharepoint site that use my windows authentication. I can use the requests module to access the site but it requires I explicitly state my windows password.

import requests
from requests_ntlm import HttpNtlmAuth

SITE = "https://sharepointsite.com/"
PASSWORD = "pw"
USERNAME = "domain\\user"

response = requests.get(SITE, auth=HttpNtlmAuth(USERNAME,PASSWORD))
print response.status_code

Python是否可以通过Windows身份验证访问该站点,所以我不必提供密码?似乎可以通过requests_nltm做到这一点,但我无法解决.

Is there a way for Python to access the site through windows authentication so I don't have to provide my password? It seems like this might be possible through requests_nltm but I can't work out how.

推荐答案

如果您不想明确声明Windows密码,则可以使用

If you don't want to explicitly state your windows password you could use the getpass module:

import requests
from requests_ntlm import HttpNtlmAuth
import getpass

SITE = "https://sharepointsite.com/"
USERNAME = "domain\\user"

response = requests.get(SITE, auth=HttpNtlmAuth(USERNAME, getpass.getpass()))
print response.status_code

通过这种方式,您不必以纯文本格式存储密码.

This way you don't have to store you password in plain text.

查看代码 >无法在不提供密码或密码哈希到HttpNtlmAuth

Looking at the code for the requests_ntlm there isn't a way to use it without supplying your password or the hash of your password to HttpNtlmAuth

这篇关于使用Windows身份验证访问Python中的Sharepoint网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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