Sharepoint Provider Hosted App: Invalid JWT Token. The token is expired
<p>I get the following error randomly when I work in my app:</p>

<blockquote>
  <p>Invalid JWT token. The token is expired. </p>
  
  <p>[SecurityTokenExpiredException: Invalid JWT token. The token is
  expired.]<br>
  Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ValidateLifetime(JsonWebSecurityToken
  token) +296<br>
  Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ValidateTokenCore(SecurityToken
  token, Boolean isActorToken) +162<br>
  EventsWeb.TokenHelper.ReadAndValidateContextToken(String
  contextTokenString, String appHostName) in C:\APP\TokenHelper.cs:120<br>
  EventsWeb.TokenHelper.GetClientContextWithContextToken(String
  targetUrl, String contextTokenString, String appHostUrl) in
  C:\APP\TokenHelper.cs:465<br>
  EventsWeb.Pages.User.tmpl.index.GetHostWebClientContext() in
  C:\APP\Pages\User\tmpl\index.aspx.cs:90<br>
  EventsWeb.Pages.User.tmpl.index.OnPreRender(EventArgs e) in
  C:\APP\Pages\User\tmpl\index.aspx.cs:69<br>
  System.Web.UI.Control.PreRenderRecursiveInternal() +107<br>
  System.Web.UI.Page.ProcessRequestMain(Boolean
  includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  +7675</p>
</blockquote>

<p>There is no way except of restarting the Internet Explorer to solve this issue.
I have this in some applications. The ClientId and ClientSecret is valid, otherwise the restart of IE won't be able to solve this problem.</p>

<p>The time when this message occurs differs. Sometimes after 1hour sometimes after 5...</p>

<p>I don't know why the token is getting invalid due the working in this app. But thats not userfriendly...</p>

<p>Any idea about this?</p>

<p>Thanks</p>