Error - Bearer error="invalid_token"
meetsekhar opened this issue · 2 comments
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApi(Configuration);
I just copied the code given in the repo and when I run the code I get Bearer error="invalid_token" error.
After going thru the documentation I even registered for the events
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(options =>
{
options.Audience = "";
options.TokenValidationParameters.ValidateAudience = false;
options.Events = new JwtBearerEvents
{
OnAuthenticationFailed = AuthenticationFailed,
OnForbidden = OnForbidden
};
options.Authority = "";
}, apiOptions =>
{
apiOptions.ClientId = "";
apiOptions.Authority = "";
apiOptions.Domain = "";
apiOptions.Instance = "https://login.microsoftonline.com";
apiOptions.TenantId = "";
apiOptions.Events = new AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents
{
OnAuthenticationFailed = OnApiAuthFailed,
OnTokenValidated = OnTokenValidated,
OnAccessDenied = OnAccessDenied,
OnRemoteFailure = OnRemoteFailure,
OnTokenResponseReceived = OnTokenResponseReceived
};
}, "Bearer", true);
None of the events registered are firing except for OnMessageReceived.
Any help appreciated
Thank you
@meetsekhar please fill out the issue template, tell us the version of your msal packages, share your configuration parameters (authConfig.js, appsettings.json) and any logs in the console. The invalid token error could be due to a number of reasons, so this info would really help us to track it down (also, if you have a public repository that we can look at, feel free to share a link to it)
Closing due to inactivity. Let us know.