protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ResourceServerConfiguration config = new ResourceServerConfiguration
            {
                EncryptionVerificationCertificate = new X509Certificate2(Server.MapPath("~/Certs/localhost.pfx"), "a"),
                IssuerSigningCertificate = new X509Certificate2(Server.MapPath("~/Certs/localhost.cer"))
            };
            GlobalConfiguration.Configuration.MessageHandlers.Add(new OAuth2Handler(config));
        }
 public OAuth2Handler(ResourceServerConfiguration configuration)
 {
     if (configuration == null) throw new ArgumentNullException("configuration");
     _configuration = configuration;
 }