I used Auth0 as Authentication Provider for one of my projects.
I did following for my Web API project.
For handling Authorization header and token, I used following Nuget Packages:
Install-Package WebApi.JsonWebToken
Install-Package Auth0-ASPNET
It adds JsonWebToken.cs and JsonWebTokenValidationHandler.cs in App_Start folder.
Opening WebApiConfig.cs add using statements
using projectName.App_Start;
using System.Web.Configuration;
and add following code snippet under Register method.
var clientID = WebConfigurationManager.AppSettings["ClientId"];
var clientSecret = WebConfigurationManager.AppSettings["ClientSecret"];
config.MessageHandlers.Add(new JsonWebTokenValidationHandler()
{
Audience = clientID,
SymmetricKey = clientSecret
});
Remove anything related to Auth0 and there you have a nice handler for extracting the JWT token and also code for validating it.
Reference: https://manage.auth0.com/