title: IdentityServer returns BadRequest invalid_grant
body: <p>The following .NET Core method returns BadRequest error:invalid_grant
  However not always, only in the middle of a session - not sure what else is needed. The request is made from a Blazor App:</p>
  <pre><code>private async Task&lt;TokenResponse&gt; RefreshAccessToken()
      {
          string authority = _configuration.GetValue(&quot;Authority&quot;, &quot;url...&quot;);
          using (HttpClient serverClient = _httpClientFactory.CreateClient())
          {
              var discoveryDocument = await serverClient.GetDiscoveryDocumentAsync(authority);
              var refreshToken = _tokenProvider.RefreshToken;
              using (HttpClient refreshTokenClient = _httpClientFactory.CreateClient())
              {
                  TokenResponse tokenResponse = await refreshTokenClient.RequestRefreshTokenAsync(
                      new RefreshTokenRequest
                      {
                          Address = discoveryDocument.TokenEndpoint,
                          RefreshToken = refreshToken,
                          ClientId = &quot;client id ...&quot;,
                          ClientSecret = &quot;secret ...&quot;
                      });
  
                  return tokenResponse;
              }
          }
      }
  </code></pre>
  <p>This is the request message:
  <a href="https://i.stack.imgur.com/9JuVb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9JuVb.png" alt="enter image description here" /></a></p>