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:
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
Solved! Go to Solution.
Views
Replies
Total Likes
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
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