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