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

JwtBearerHandler.HandleAuthenticateAsync() - Object reference not set to an instance of an object. #4

Open
RedBlack-DevOps opened this issue Dec 19, 2023 · 0 comments

Comments

@RedBlack-DevOps
Copy link

We were getting the below error in one of our projects.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

We resolved it by changing the example LegacyOAuthSecurityTokenHandler to return validatedToken = new DummyWebToken();instead of validatedToken = default(SecurityToken);

public class DummyWebToken : SecurityToken
{
    public override string Id => "Id";

    public override string Issuer => "Issuer";

    public override DateTime ValidFrom => new DateTime();

    public override DateTime ValidTo => new DateTime();

    public override SecurityKey SecurityKey => throw new NotImplementedException();

    public override SecurityKey SigningKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
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