我正在尝试在Web API应用程序中使用OAuth承载身份验证,一切正常在我的本地IIS上运行,我可以获取令牌,如您所见:
但是,当我将项目发布到Azure中的ApiApp时,它根本不起作用。我得到了答复:
{ “message”:“找不到与请求URI'https://mysite.azurewebsites.net/API/login'匹配的HTTP资源。”, “messageDetail”:“找不到与名为'login'的控制器匹配的类型。” }
如下所示:
My Startup.Auth类看起来像:
public partial class Startup
{
public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
public static string PublicClientId { get; private set; }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
// Configure the application for OAuth based flow
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/login"),
Provider = new ApplicationOAuthProvider(),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
// In production mode set AllowInsecureHttp = false
//#if DEBUG
AllowInsecureHttp = true
//#endif
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthAuthorizationServer(OAuthOptions);
}
}
我希望你能告诉我我做错了什么。
答案 0 :(得分:0)
我发现我使用了不正确的网址。我使用/ api / login而不是/ login。