(I came across a similar situation in .Net, so in the context of this)
No, if you use oauth, you do not need to write a new validation token method. Because OAuthBearerAuthenticationProvider does this behind the scenes
app.UseJwtBearerAuthentication( new JwtBearerAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AllowedAudiences = new[] { audience }, IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[] { new SymmetricKeyIssuerSecurityTokenProvider(issuer, secret) }, Provider = new OAuthBearerAuthenticationProvider { OnValidateIdentity = context => { context.Ticket.Identity.AddClaim(new System.Security.Claims.Claim("newCustomClaim", "newValue")); return Task.FromResult<object>(null); } } });
(according to my experience). But if you want, it is possible to configure the Provider in your "startup" file:
app.UseJwtBearerAuthentication( new JwtBearerAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AllowedAudiences = new[] { audience }, IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[] { new SymmetricKeyIssuerSecurityTokenProvider(issuer, secret) }, Provider = new CustomOAuthBearerProvider() });
CustomOAuthBearerProvider inherits the IOAuthBearerAuthenticationProvider interface, which has a predefined signature for the RequestToken () method, and this method is called before any validation for the token. Therefore, I think you can use it for your custom token validation operations, and then send the token for OAuth verification.
source share