JS Client: Chrome login popup when authentication fails

Hello community

I'm having some problems with chrome and the basic authentication (jquery) with the javascript client from nuxeo. I have a form based login which works fine when the credentials are ok, but when the authentication fails, I get a popup from chrome asking for the credentials again. I have spent some time doing research and found out that this happens because chrome is getting a 401 response, and it automatically shows the popup. I tried several solutions as altering the Authorization header to other thing than “Basic …” but I haven't had any luck. I wonder if any of you guys have come across this before and found a workaround.

This is my connection code, nuxeo's js library is untouched.

        var nuxeoclient = new nuxeo.Client({
            baseURL: 'http://localhost:8080/nuxeo',
            restPath: 'site/api/v1',
            automationPath: 'site/api/v1/automation',
            auth: {
                method: 'basic',
                username: form.username.value,
                password: form.password.value
            },
            timeout: 30000

        })
        var h = nuxeoclient._headers;
        nuxeoclient._computeAuthentication(h);

        nuxeoclient.connect(function(error, client) {
            if (error) {
                //do stuff
            }else{
                ///blah blah
            }
        });
1 votes

1 answers

1446 views

ANSWER



Hi,

You can add the X-No-Basic-Header header to avoid browser popup for authentication.

...
client.header('X-No-Basic-Header', true);
client.connect(...)
...
2 votes



Thank you Thomas, it worked!
09/17/2015