public void Load() { lock (FileLock) { string jsonCache = (string)context.Session[CacheId]; if (!string.IsNullOrEmpty(jsonCache)) { Tokens = JsonConvert.DeserializeObject <SessionTokenEntry>(jsonCache); } } }
public void UpdateTokens(TokenRequestSuccessResponse tokenResponse) { double expireSeconds = double.Parse(tokenResponse.ExpiresIn); expireSeconds += -300; Tokens = new SessionTokenEntry() { AccessToken = tokenResponse.AccessToken, RefreshToken = tokenResponse.RefreshToken, ExpiresOn = DateTime.UtcNow.AddSeconds(expireSeconds) }; Persist(); }