Applications at AppHarbor sit behind an NGINX load balancer. Because of this, all requests that hit the client app will come over HTTP as the SSL will be handled by this front end.
ASP.NET MVC's OAuth 2 OAuthAuthorizationServerOptions has options to restrict access to token requests to only use HTTPS. The problem is, unlike a Controller or ApiController, I don't know how to allow these forwarded requests through when I specify AllowInsecureHttp = false.
Specifically, in the app startup/config:
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions {
AllowInsecureHttp = true,
});
Needs to somehow do this check internally and if it's true, treat it as SSL:
HttpContext.Request.Headers["X-Forwarded-Proto"] == "https"
Here's how I do it using MVC Controller's by applying a custom Filter Attribute: https://gist.github.com/runesoerensen/915869