Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2018-10-03 09:23 AM
Hello!
To use WS API in my custom objects, I need session token.
Since 6.1 it was possible to get it like this:
var sessionToken = parent.parent.ArcherApp.globals.workpointFeatures.SessionToken;
But, I've recently updated to 6.4 SP1 P1, and ArcherApp.globals.workpointFeatures is now a JSON string encoded into base64.
That requires me to do decoding, and then double deserialization to parse JSON:
var sessionToken = Sys.Serialization.JavaScriptSerializer.deserialize(Sys.Serialization.JavaScriptSerializer.deserialize(atob(parent.parent.ArcherApp.globals.workpointFeatures))).SessionToken;
Is there any easier way to get session token?
2018-10-03 09:33 AM
Nope
This is what I use, and it about the same thing your're doing:
var sessionToken = JSON.parse(JSON.parse(atob(parent.parent.ArcherApp.globals.workpointFeatures))).SessionToken
Advisory Consultant
2018-10-03 09:33 AM
Nope
This is what I use, and it about the same thing your're doing:
var sessionToken = JSON.parse(JSON.parse(atob(parent.parent.ArcherApp.globals.workpointFeatures))).SessionToken
Advisory Consultant
2018-10-03 01:29 PM
What about Headers? Like
x-csrf-token
2018-10-03 01:33 PM
Definitely not the user session token
It's the Cross-Site Request Forgery token.
The session token is also in a read-only cookie; client side scripts can't read it.
Advisory Consultant
2018-10-03 01:35 PM
Ah, okay, but I meant, is not it so that all session elements are stored also in Headers?
2018-10-03 01:37 PM
Not really. Either in application variables, ASP.NET viewstate or cookies.
Advisory Consultant
2018-10-03 01:40 PM
Great, thanks!
2023-04-25 05:36 PM
Hi David, The following doesn't seem to work anymore. Is there an alternative way to obtain the session token?
var sessionToken = JSON.parse(JSON.parse(atob(parent.parent.ArcherApp.globals.workpointFeatures))).SessionToken
2023-04-26 09:15 AM
2023-04-26 09:17 AM
Thanks. I got it to work eventually. It was returning undefined initially.