示例#1
0
 public void Load()
 {
     lock (FileLock)
     {
         string jsonCache = (string)context.Session[CacheId];
         if (!string.IsNullOrEmpty(jsonCache))
         {
             Tokens = JsonConvert.DeserializeObject <SessionTokenEntry>(jsonCache);
         }
     }
 }
示例#2
0
        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();
        }