如何解决无法使用HTTPDigestAuth创建会话?
我正在尝试以异步方式发出GET
请求。并且客户端身份验证系统已经使用DigestAuth进行了实现。
async def run(self,url_list,api_auth):
sem = asyncio.Semaphore(10)
tasks = []
async with ClientSession(auth = HTTPDigestAuth("user_name","password")) as session:
for url in url_list:
task = asyncio.ensure_future(self.get_content(sem,url,session))
tasks.append(task)
response = await asyncio.gather(*tasks)
logging.critical(f"Total size of response: {len(response)}")
TypeError:而是需要BasicAuth()元组
当我使用BasicAuth()
创建身份验证元组时。
async def run(self,api_auth):
sem = asyncio.Semaphore(10)
tasks = []
async with ClientSession(auth = BasicAuth("user_name","password",verify=True)) as session:
for url in url_list:
task = asyncio.ensure_future(self.get_content(sem,session))
tasks.append(task)
response = await asyncio.gather(*tasks)
logging.critical(f"Total size of response: {len(response)}")
401
-未经授权
是否有适当/解决方法来解决此问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。