Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

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

Avatar

Level 7

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