I m trying to validate token generated from IDS4 using IdentityServer3.AccessTokenValidation , but i receive 401 everytime.
I had followed the suggestion i saw in different articles:
- IdentityServer4 IdentityServer3.AccessTokenValidation
- https://andrewlock.net/debugging-jwt-validation-problems-between-an-owin-app-and-identityserver4-2/
- https://github.com/joaocolombo/IS4/blob/master/ApiIdentity/ApiIdentityNetFramework/Startup.cs
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
var executingAssembly = Assembly.GetExecutingAssembly();
Api.Register(builder, executingAssembly);
builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration);
builder.RegisterAssemblyModules(executingAssembly);
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
var webApiResolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = webApiResolver;
app.UseCors(CorsOptions.AllowAll);
app.UseAutofacWebApi(config);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
var options = new IdentityServerBearerTokenAuthenticationOptions
{
Authority = ConfigurationManager.AppSettings["IdentityServer:Authority"],
AuthenticationType = "Bearer",
RequiredScopes = new[] { ConfigurationManager.AppSettings["IdentityServer:ApiScope"] },
};
app.UseIdentityServerBearerTokenAuthentication(options);
WebApiConfig.Register(config);
config.Filters.Add(new AuthorizeAttribute());
app.UseWebApi(config);
}
This should authorize the token i send from app, however The authorization is applied to all the controllers, but i see the controller's constructor is being hit but the action isn't getting called, does that mean the validation of token is working fine? but i see the Authority i'm sending is correct also.
i get the following error after i turned on katana logging :
IdentityServer3.AccessTokenValidation.ValidationEndpointTokenProvider Information: 0 : Error returned from token validation endpoint: Not Found Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware Warning: 0 : invalid bearer token received