在 Google Chrome 中传递基本身份验证凭据再次显示弹出窗口 [英] Passing basic auth credentials in Google Chrome shows the pop again

查看:92
本文介绍了在 Google Chrome 中传递基本身份验证凭据再次显示弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 watir(Ruby selenium 包)尝试使用基本身份验证登录到 url

I am using watir(Ruby selenium package) to try and login to url using basic auth

我像这样传递凭据

 https://username:password@nagios.com

但是,当浏览器打开时,我会弹出一个再次输入凭据的窗口.

However when the browser opens, i get a popup to enter the credentials again.

我使用的代码如下

driver = Watir::Browser.new :chrome
driver.goto "https://username:password@nagios.com"

上面的代码打开浏览器 -> 转到 url 但弹出窗口再次输入凭据.

The above code opens the browser -> goes to the url but give the popup to enter the credentials again.

如何使用基本身份验证登录网址?

How do i login to the url using basic auth?

推荐答案

原来 Chrome 在 52 版之后不再支持在 url 中传递凭据.更多信息 https://medium.com/@lmakarov/say-goodbye-to-urls-with-embedded-credentials-b051f6c7b6a3

Turns out that Chrome has stopped supporting passing credentials in the url after version 52. more info https://medium.com/@lmakarov/say-goodbye-to-urls-with-embedded-credentials-b051f6c7b6a3

要解决此问题,您需要在启动浏览器时设置一个参数 --disable-blink-features="BlockCredentialedSubresources".这样做是为了禁用该功能

To fix this you need to set an argument --disable-blink-features="BlockCredentialedSubresources" while launching the browser. what this does is that it disable that feature

更多信息 绕过阻止URL 包含嵌入式凭据的子资源请求

这是我最终有效的代码

 args = ['--disable-software-rasterizer',
                    '--disable-blink-features="BlockCredentialedSubresources"',
                    '--no-proxy-server',
                    '--disable-gpu',
                    '--no-sandbox',
                    '--ignore-certificate-errors']
driver = Watir::Browser.new :chrome, options: {args: args}
driver.goto "https://username:password@nagios.com"

这篇关于在 Google Chrome 中传递基本身份验证凭据再次显示弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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