2016-08-14 36 views
0

我试图在Web API应用程序来使用OAuth认证的承载,一切工作正常在我的本地IIS,我能够获得令牌,你可以在这里看到:➤为什么OAuth承载认证在发布到Azure中的API应用时无法在MVC Web API中工作?

enter image description here

但是,当我将我的项目发布到Azure中的ApiApp,它根本不起作用。我得到的回应:

{ “消息”:“没有HTTP资源发现匹配的请求URI‘https://mysite.azurewebsites.net/API/login’。”, “messageDetail”:“没有类型被发现,命名为‘登录’控制器匹配“。 }

如图这里:

enter image description here

我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

我刚刚发现我使用的是不正确的网址。我使用/ api/login而不是/ login。

相关问题