cancel
Showing results for 
Search instead for 
Did you mean: 

Session Token in Custom Object

SergeiBakhaev
Contributor III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

DavidPetty
Archer Employee
Archer Employee

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 - Archer, an RSA Business

View solution in original post

6 REPLIES 6

DavidPetty
Archer Employee
Archer Employee

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 - Archer, an RSA Business

What about Headers? Like 

x-csrf-token

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 - Archer, an RSA Business

Ah, okay, but I meant, is not it so that all session elements are stored also in Headers?

Not really.  Either in application variables, ASP.NET viewstate or cookies.

 Advisory Consultant - Archer, an RSA Business

Great, thanks!