Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用python访问sharepoint列表_Python_Sharepoint_Urllib2 - Fatal编程技术网

无法使用python访问sharepoint列表

无法使用python访问sharepoint列表,python,sharepoint,urllib2,Python,Sharepoint,Urllib2,我正在使用python sharepoint从我的sharepoint帐户访问数据。但是我总是得到一个urllib2.HTTPError:HTTPError 403:probled错误。我跟在后面。这是我的密码: from sharepoint import SharePointSite, basic_auth_opener server_url = 'https://myServerUrl.sharepoint.com/' site_url = server_url + 'sites/test

我正在使用python sharepoint从我的sharepoint帐户访问数据。但是我总是得到一个
urllib2.HTTPError:HTTPError 403:probled
错误。我跟在后面。这是我的密码:

from sharepoint import SharePointSite, basic_auth_opener
server_url = 'https://myServerUrl.sharepoint.com/'
site_url = server_url + 'sites/test'
username = 'myUsername.onmicrosoft.com'
password = 'myPassword'

opener = basic_auth_opener(server_url, username, password)
site = SharePointSite(site_url, opener)
for sp_list in site.lists:
    print (sp_list)
我还尝试将urllib2 opener创建为:

from sharepoint import SharePointSite
from ntlm import HTTPNtlmAuthHandler
import urllib2

password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(None, server_url, username, password)
auth_handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(password_manager)
opener = urllib2.build_opener(auth_handler)

site = SharePointSite(site_url, opener)
for sp_list in site.lists:
    print (sp_list)
但同样的错误。任何解决方案都将不胜感激

SharePoint Online不支持基本或NTLM身份验证方法,这不是最佳选择

相反,我建议尝试支持Office 365/SharePoint Online

下面是一个类似的示例,用于获取站点中的所有列表并打印其标题

ctx_auth = AuthenticationContext(url='https://contoso.sharepoint.com')
if ctx_auth.acquire_token_for_user(username='jdoe@contoso.onmicrosoft.com'],
                                   password='--password--'):

    ctx = ClientContext(settings['url'], ctx_auth)
    lists = ctx.web.lists
    ctx.load(lists)
    ctx.execute_query()
    for l in lists:
        print(l.properties["Title"])

您正在使用哪个版本的SharePoint?现在我正在试用office 365 SharePoint。这是一个很棒的库。它需要更多的识别,谢谢你的帮助。嗨,瓦迪姆,我得到了以下错误,有没有办法明确指定验证\u ssl=None为poc?“错误:HTTPSConnectionPool(host='login.microsoftonline.com',port=443):url:/GetUserRealm.srf超过最大重试次数(由SSLError(SSLCertVerificationError(1),[SSL:CERTIFICATE\u Verification\u FAILED]CERTIFICATE Verification失败:无法获取本地颁发者证书(_SSL.c:1076))”值错误:无法从获取二进制安全令牌