Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Continuous loop and "Invalid grant" error during token refresh #1938

Open
JoelDennyJoseph opened this issue May 13, 2024 · 0 comments

Comments

@JoelDennyJoseph
Copy link

JoelDennyJoseph commented May 13, 2024

Version

^17.0.0

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

After logging in using a custom Dotnet authorization server that implements Openiddict and using the angular-auth-oidc-client package version 17, I encountered a continuous loop issue during token refresh. The token refresh enters into a loop of calls to connect/token, with each call being canceled and replaced by another call. This loop eventually ends with an "Invalid grant" error. This causes 100% CPU utilization in the authorization server, leading to the application being slow overall.

Operating System: Windows
Angular Version: Version 17
Package Configuration: 
    authority: ********,
    redirectUrl: window.location.origin,
    postLogoutRedirectUri: window.location.origin,
    clientId: ********,
    scope: ********,
    responseType: 'code',
    silentRenew: true,
    renewTimeBeforeTokenExpiresInSeconds: 120,
    useRefreshToken: true,
    logLevel: LogLevel.Debug,
    ignoreNonceAfterRefresh: true,

Server Environment: 
    Dotnet Version=8.0.0
    Microsoft.AspNetCore.OpenApi Version=8.0.0
    Microsoft.EntityFrameworkCore.Design Version=8.0.0
    Microsoft.AspNetCore.Authentication.Google Version=8.0.0
    Microsoft.AspNetCore.Authentication.OpenIdConnect Version=8.0.0
    Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore Version=8.0.0
    Microsoft.AspNetCore.Identity.EntityFrameworkCore Version=8.0.0
    Microsoft.AspNetCore.Identity.UI Version=8.0.0
    Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation Version=8.0.0
    Microsoft.EntityFrameworkCore.SqlServer Version=8.0.0
    Microsoft.EntityFrameworkCore.Tools Version=8.0.0
    OpenIddict.AspNetCore Version=4.9.0
    OpenIddict.EntityFrameworkCore Version=4.9.0
    OpenIddict.Quartz Version=4.9.0
    Quartz.Extensions.Hosting Version=3.8.0

Steps to reproduce the behavior

1. Log in to the application using the custom Dotnet authorization server.
2. Wait until either the ID token or the access token expires.
3. The application attempts to refresh the token by calling the endpoint connect/token.
4. Observe that after a few successful silent refresh calls, the refresh call starts to fail, leading to a
continuous loop of calls to connect/token.
5. Eventually, the final call fails with an error message stating "Invalid grant."

This error mostly occurs when the application is idle for long time.

Application source code - https://github.com/JoelDennyJoseph/AuthTestApp

A clear and concise description of what you expected to happen.

The token refresh should occur smoothly without entering into a continuous loop, and there should be no "Invalid grant" error.

Additional context

error console
error network tab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant