我可以使用httplib2进行抢占式身份验证吗? [英] Can I do preemptive authentication with httplib2?
本文介绍了我可以使用httplib2进行抢占式身份验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要针对HTTP服务器执行抢占式基本身份验证,即立即进行身份验证,而无需等待401响应.可以使用httplib2吗?
I need to perform preemptive basic authentication against an HTTP server, i.e., authenticate right away without waiting on a 401 response. Can this be done with httplib2?
我通过在请求中添加一个Authorization标头来解决该问题,如公认的答案所示:
I solved it by adding an Authorization header to the request, as suggested in the accepted answer:
headers["Authorization"] = "Basic {0}".format(
base64.b64encode("{0}:{1}".format(username, password)))
推荐答案
在初始请求中添加适当格式的授权"标头.
Add an appropriately formed 'Authorization' header to your initial request.
这篇关于我可以使用httplib2进行抢占式身份验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文