ASP.NET oAuth通过SSL访问令牌

fai*_*sal 4 asp.net ssl https oauth-2.0 asp.net-web-api

我按照这篇文章http://www.asp.net/web-api/overview/security/working-with-ssl-in-web-api通过https强制执行所有api调用.

我使用Visual Studio模板之一通过以下代码启用oAuth:

        OAuthOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/Token"),
            Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
            AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
            AllowInsecureHttp = true
        };
Run Code Online (Sandbox Code Playgroud)

这基本上说我们可以通过http://server.com/Token网址请求访问令牌.

我的问题是如何通过SSL强制执行令牌检索(任何非https请求令牌的请求都将被拒绝).

fai*_*sal 9

找到解决方案,AllowInsecureHttp = true从OAuthOptions中删除,如果有人想知道的话.