How to pass input credentials for xtk:session#logon web service | Community
Skip to main content
Level 6
January 8, 2022
Solved

How to pass input credentials for xtk:session#logon web service

  • January 8, 2022
  • 1 reply
  • 1242 views

Hello Folks,

Hope you're doing well

We are leveraging OOTB provided API's for our requirement, as a part of it I am doing 2 calls:

  • To Xtk:Session#Logon Service to generate a session token, security token.
  • To Xtk:Session#Write by supplying required parameters along with Session Token for Authorization

I was able to do this from SOAP by passing credentials (username/password) to get session token and write data, but when it comes to doing via code (JavaScript), how can I pass credentials as input to generate session token thereby ensuring it is not visible anywhere in Code ? Is there anyway to mask credentials ?

Please help with suggestions

@adhiyan @jonathon_wodnicki @vraghav @_manoj_kumar_ 

Thanks,

SSB

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Milan_Vucetic

Hi @surabattulasr 

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

1 reply

Milan_Vucetic
Milan_VuceticAccepted solution
Level 9
January 9, 2022

Hi @surabattulasr 

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