Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

Level 6

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 @Vipul_Raghav @Manoj_Kumar_ 

Thanks,

SSB

1 Accepted Solution

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

1 Reply

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