Avatar

Correct answer by
Community Advisor

Hi @Ssb_94 

you can use the following:

function getToken(url, username, password) {

    var cnx = new HttpSoapConnection(url);
    var session = new SoapService(cnx, 'urn:xtk:session');

    session.addMethod("Logon", "xtk:session#Logon",
        ["sessiontoken", "string", "Login", "string", "Password", "string", "Parameters", "NLElement"],
        ["sessionToken", "string", "sessionInfo", "NLElement", "securityToken", "string"]);

    var res = session.Logon("", username, password,  <param/>);
    var token = res[0];
    var securityToken = res[2];

    return {
        token: token,
        securityToken: securityToken
    };
}

You can encrypt credentials and store them within the options. When call above function you can decrypt them in JS and pass as parameters.

 

Regards,
Milan

View solution in original post