示例#1
0
 /// <summary>
 /// Refresh Access Token if it is need
 /// </summary>
 public void RefreshAccessToken()
 {
     if (token == null)
     {
         throw new Exceptions.VATAPIInvalidToken(Model.error.IMPOSSIBLE_TO_REFRESH_TOKEN);
     }
     if (token.UtcExpiredOn == null || token.UtcExpiredOn?.AddMinutes(-15) < token.UtcNow)
     {
         ApplicationProcessor.RefreshAccessToken(token, application);
         updateOAuthToken(token);
     }
 }
示例#2
0
 /// <summary>
 /// Refresh Access Token if it is need
 /// </summary>
 private bool RefreshAccessToken()
 {
     if (token == null || token.RefreshToken == null)
     {
         throw new Exceptions.VATAPIInvalidToken(Model.error.IMPOSSIBLE_TO_REFRESH_TOKEN);
     }
     if (token.UtcExpiredOn == null || token.UtcExpiredOn?.AddMinutes(-15) < System.DateTime.UtcNow)
     {
         try
         {
             ApplicationProcessor.RefreshAccessToken(application, token);
             saveOAuthToken(token);
         }
         catch (Exception ex)
         {
             Trace.WriteError(ex);
             //         throw;
         }
     }
     return(false);
 }