404 Not Find When using Owin with OAuth
在使用Owin+OAuth时,一步一步的测试时,在用
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14)
//AllowInsecureHttp = true
};
app.UseOAuthBearerTokens(OAuthOptions);注册中间件时,
客户端在调用
var loginData =
{
grant_type: 'password',
username: self.loginEmail(),
password: self.loginPassword() };
$.ajax({
type: 'POST',
url: '/Token',
data: loginData }).done(
function (data) {
self.user(data.userName);
// Cache the access token in session storage.
sessionStorage.setItem(tokenKey, data.access_token);
}).fail(showError);
出现404. Not Fount错误,这显然是/Token endpoint没有启作用。在网上找到是要把AllowInsecureHttp=true打开,应该是缺省用https协议,如果没有打开它,就没有办法调用/Token endpoint的服务