In my C# Startup.cs I configure OAuth like follows
OAuthAuthorizationServerOptions oauthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/API/Authorize/Token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
In JavaScript I can access the C# AccessTokenExpireTimeSpan
property from the expires_in
property on the JavaScript response object. To get the Date and Time, in JavaScript, when the token expires I was hoping to do something as simple as follows
var tokenExpireDate = (new Date()).Add(response.expires_in); // want something like this
How could I get something like above so that I can add a C# TimeSpan value to a Date object in JavaScript?
EDIT: Thanks to zerkms point of being able to first convert the JavaScript Date object to seconds I was able to successfully get the future Date and Time in JavaScript using the line below. Is there any way to clean this up or is this about the best we got?
var tokenExpireDate = new Date((((new Date()).getTime() / 1000) + response.expires_in) * 1000);
Thanks.