Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
994 views
in Technique[技术] by (71.8m points)

authentication - Passing basic auth credentials in Google Chrome shows the pop again

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

I pass the credentials like so

 https://username:[email protected]

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

The code that i use is as follows

driver = Watir::Browser.new :chrome
driver.goto "https://username:[email protected]"

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

More info Bypass blocking of subresource requests whose URLs contain embedded credentials

This is my final code which works

 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:[email protected]"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...