this._initAuthentication is not a function

It's my first time using nuxeo.js. I added nuxeo.js to the mvc application Scripts folder and made the reference to it in my .aspx page head section. I'm trying to access nuxeo server with this code:

$(document).ready(function () {

var client = new nuxeo.Client({<br/>        
    baseURL: '',<br/>
    restPath: 'api/v1',<br/>
    automationPath: 'site/api/v1/automation',<br/>
    auth: {<br/>
        method: 'basic',<br/>
        username: 'myusername',<br/>
        password: 'mypassword'<br/>
    timeout: 30000       <br/>


My browser console error list always get the message: “Uncaught TypeError: this._initAuthentication is not a function”

Debugging I realized that in line 43 of nuxeo.js we have a call to this._initAuthentication() and I can't find the implementation to this function. I am probably missing something.

Can anyone give me a help?

0 votes

2 answers




My bad, I've done a fix.

You can try to use the updated client:

Will post a new version 0.5.1 to bower (if you're using it).

Thanks for the report.

1 votes

Now I don't get any error but the object client has always it's connected property set to false. I'm sure that it's not connected because even if I put a wrong password I have the same client object as return. Furthermore, every request I try to do like the example below gives null as return. client.request('user/Administrator') </br> .get(function(error, user) {</br> if (error) {</br>

 // something went wrong&lt;/br&gt;
 throw error;&lt;/br&gt;


console.log(user)</br> });


Could you share your whole code? Through a gist for instance.


0 votes

I'm just trying to get any data from the nuxeo server using nuxeo.js in my MVC application. So my code is exactly this:

$(document).ready(function () {<br/> <br/>

var client = new nuxeo.Client({&lt;br/&gt;
    baseURL: &apos;;,&lt;br/&gt;
    restPath: &apos;site/api/v1/&apos;, &lt;br/&gt;
    automationPath: &apos;site/api/v1/automation/&apos;, &lt;br/&gt;
    auth: { &lt;br/&gt;
        method: &apos;basic&apos;, &lt;br/&gt;
        username: &apos;myuser&apos;, &lt;br/&gt;
        password: &apos;mypassword&apos; &lt;br/&gt;
    }, &lt;br/&gt;
    timeout: 30000 &lt;br/&gt;
}); &lt;br/&gt;


client.connect(function (error, client) { &lt;br/&gt;
    if (error) { &lt;br/&gt;
        // cannot connect &lt;br/&gt;
        throw error; &lt;br/&gt;
    } &lt;br/&gt;
    // OK, the returned client is connected &lt;br/&gt;
    console.log(&apos;Client is connected: &apos; + client.connected); &lt;br/&gt;
}); &lt;br/&gt;


client.request(&apos;user/Administrator&apos;) &lt;br/&gt;
.get(function(error, user) { &lt;br/&gt;
    if (error) { &lt;br/&gt;
        // something went wrong &lt;br/&gt;
        throw error; &lt;br/&gt;
    } &lt;br/&gt;


    console.log(user) &lt;br/&gt;
}); &lt;br/&gt;

}); <br/> <br/> The results in the console are: <br/> Client is connected: false <br/> null <br/> I have this error message in the console:<br/> XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:52652' is therefore not allowed access. The response had HTTP status code 401.