title: Why IdentityServer 4 code flow gets invalid_grant response some times later?
body: <p>I am using identityserver4 code flow for my angular application. I am using <a href="https://www.npmjs.com/package/angular-oauth2-oidc/v/8.0.4" rel="nofollow noreferrer">angular-oauth2-oidc</a> library.</p>
  <p>My configuration is like this:</p>
  <pre><code>   OauthConfig: AuthConfig = {
          issuer: 'http://mydomain.identityserver4',
          requireHttps: false,
          responseType: &quot;code&quot;,
          redirectUri: window.location.origin + '/index.html',
          clientId: 'dev.code.flow',
          scope: 'openid profile offline_access my.api',
          logoutUrl: window.location.origin + '/index.html',
          postLogoutRedirectUri: window.location.origin + '/index.html'
      }
  
    private configureOauth(){
      this.oauthService.configure(OauthConfig);
      this.oauthService.tokenValidationHandler = new JwksValidationHandler();
      this.oauthService.loadDiscoveryDocumentAndLogin();
      this.oauthService.setupAutomaticSilentRefresh();
    }
  </code></pre>
  <p>After I login the application, the library sends refresh token request every 5 minutes. I can see this in chrome developer tools.</p>
  <p>But several hours later, the token refresh request gets a 400 (Bad request) error. Error message is <code>error: &quot;invalid_grant&quot;</code></p>
  <p>What could be the reason for this?</p>