Gopinath D
Gopinath D

Reputation: 177

Sending credentials in url is not supported in chrome 59

I have a basic authentication for a SSRS report server, to avoid the login pop up window while hitting a SSRS report server from a web server. I'm sending the credentials in url itself. It was working upto google chrome 58, but now it is updated to chrome 59. Now i'm not able to send credentials in the browser url.

Example https://gooduser:[email protected]

username : gooduser password : secredpassword

Kindly help on this please!

Upvotes: 2

Views: 7896

Answers (2)

You can use the "MultiPass for HTTP basic authentication" Chrome Extension to handle this.

You can do via GitHub MultiPass for HTTP basic authentication

(or)

Download the extension from Chrome Web Store - MultiPass Chrome Extension

(Or)

Download the extension as crx. You can get it as crx from chrome-extension-downloader

Once you download the Extension as crx File - Configuring the same into your Test/Source is very simple.

And this can be tested using the Sample Basic Auth-Site.

public class ChromeAuthTest {

    WebDriver driver;

    public ChromeAuthTest() {
        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
    }

    private void initDriver() {
        ChromeOptions cOptions = new ChromeOptions();
        cOptions.addExtensions(new File("MultiPass-for-HTTP-basic-authentication_v.crx"));
        driver = new ChromeDriver(cOptions);
        configureAuth(
                "https://the-internet.herokuapp.com/basic_auth",
                "admin",
                "admin");
    }

    private void configureAuth(String url, String username, String password) {
        driver.get("chrome-extension://enhldmjbphoeibbpdhmjkchohnidgnah/options.html");
        driver.findElement(By.id("url")).sendKeys(url);
        driver.findElement(By.id("username")).sendKeys(username);
        driver.findElement(By.id("password")).sendKeys(password);
        driver.findElement(By.className("credential-form-submit")).click();
    }

    public void doTest() {
        initDriver();
        driver.get("https://the-internet.herokuapp.com/basic_auth");
        System.out.println(driver.getTitle());
        driver.quit();
    }

    public static void main(String[] args) {
        new ChromeAuthTest().doTest();
    }
}

NOTE: This is taken from this Answer.

Hope this helps!

Upvotes: 0

Stefan Kanev
Stefan Kanev

Reputation: 311

I solve the same problem with chrome extension.

In extension background.js

chrome.extension.onMessage.addListener(  function(request, sender, sendResponse){
   chrome.webRequest.onAuthRequired.addListener(
        function(details, callbackFn) {
            console.log("onAuthRequired!", details, callbackFn);
            callbackFn({
                authCredentials: {username: request.username, password: request.password }
            });
        },
        {urls:  request.url + "/*"]},
        ['asyncBlocking']
    );
});

in extension contentscript.js

window.addEventListener("message", function(event) {
  if ( event.type == "BASIC_AUTH" ) {
    chrome.runtime.sendMessage(  
            event.data, 
            event.data.sender, 
            function (response) {}       
        ); 
  }
}); 

in HTML javascript

window.postMessage({ type: "BASIC_AUTH", url:"www.mydomain.com", username:"myusername", password:"mypassword" }, "*");

If you like use extensions from Chrome Web Store like : MultiPass for HTTP basic authentication

Upvotes: 1

Related Questions