Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

get session token on angular client

karanshah
ServiceNow Employee
ServiceNow Employee

I am working with angular and would like to get the session token. I tried using g_user but that didnt help. How to get the session token on client side ?

3 REPLIES 3

ChrisBurks
Giga Sage

In Service Portal the client side and server side can communicate with each other very easily. Is there a specific reason why it has to start at the client side?



Example of getting the session id from server script to client script in a widget:



Server side Script:


data.sessionID = gs.getSessionID();




Client Side:


c.sessionID = c.data.sessionID;


or if you bring in $scope and are not using c


$scope.sessionID = $scope.data.sessionID;




in the HTML markup


if you're using c


<p> {{ c.data.sessionID }} </p>


or if not


<p>{{ data.sessionID }}</p>



Hopefully that helps.


josh_nerius
ServiceNow Employee
ServiceNow Employee

Hi Karan,



Check out Session IDs and Angular apps by ajs.


I guess I have Service Portal on my mind. But I see Karan just specifically said "angular".


Thanks Josh for pointing out the article.