Reputation: 2626
I am using following method to sign in to ArcGIS portal and get the token
public static IArcGISSingleSignon SingleSignon
{
get
{
if (_singleSignon == null)
_singleSignon = new ESRI.ArcGIS.SystemUI.ArcGISSingleSignonClass();
return _singleSignon;
}
}
internal static void SignIn()
{
string bsToken = string.Empty, bsReferrer = string.Empty, bsUser = string.Empty;
int IExpiration = 0;
try
{
SingleSignon.GetToken(0, ref bsToken, ref bsReferrer, ref IExpiration, ref bsUser);
}
catch (System.Runtime.InteropServices.COMException)
{ }
}
Documentation of the GetToken method says this about the IExpiration
lExpiration is a parameter of type long
So how do I know from this long value when my token is going to expire?
Upvotes: 1
Views: 891
Reputation: 331
The value returned is the expiration time of the token in milliseconds since Jan. 1, 1970 (UTC). You can convert it to your local time by doing
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return epoch.AddMilliseconds(longValue).ToLocalTime();
Upvotes: 2