小编bad*_*guy的帖子

Python中的摘要式身份验证?

我正在尝试使用python从我的公司服务器访问页面。第一路径返回401:未授权(服务器确实需要域用户名/ pwd进行身份验证)。标头内容如下,它似乎支持3种身份验证协议,即Negotiate,NTLM和Digest,所以据我所知,我可以选择其中的一种,对吗?

Content-Type: text/html
Server: Microsoft-IIS/7.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
WWW-Authenticate: Digest qop="auth",algorithm=MD5-sess,nonce="+Upgraded+v184080dc2d18fe10d63520db505929b5b5b929ec98692ce010e80d6347b7a35d4027e59e277ac4fe1c257a95196071258a8e0797bf6129f76",charset=utf-8,realm="Digest"
X-Powered-By: ASP.NET
Date: Tue, 06 Aug 2013 09:24:44 GMT
Connection: close
Content-Length: 1293
Set-Cookie: LB-INFO=1065493258.20480.0000; path=/
Run Code Online (Sandbox Code Playgroud)

我正在使用以下python代码,但仍然出现401错误错误,有人可以告诉我如何实现吗?我应该使用NTLM吗?提前致谢!

p = urllib2.HTTPPasswordMgrWithDefaultRealm()
p.add_password(None, self.url, username, password)
handler = urllib2.HTTPDigestAuthHandler(p)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)

f = opener.open(self.url)
Run Code Online (Sandbox Code Playgroud)

python authentication ntlm digest

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

authentication ×1

digest ×1

ntlm ×1

python ×1