我有一个使用Aurelia作为前端和WEB API的点网核心的应用程序。
我必须在我的WEB API周围添加一些身份验证和授权。我正在尝试为此目的使用OAuth(Microsoft.Owin.Security.OAuth)。
我在这里有几个问题
我从一个最小的项目开始,只是更新了我的启动课程。
这是我在启动类中的configure services方法
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddOAuth("", Options =>
{
Options.ClientId = "MyApp";
Options.ClientSecret = "MyAppSecret";
Options.CallbackPath = new PathString("//");
Options.AuthorizationEndpoint = "https://localhost:44360/account/authorize";
Options.TokenEndpoint = "https://localhost:44360/account/token";
Options.Events.OnCreatingTicket = async context =>
{
};
Options.Events.OnRemoteFailure = async context =>
{
};
Options.Events.OnTicketReceived = async context =>
{
};
Options.Events.OnRedirectToAuthorizationEndpoint = async context =>
{
};
});
错误
<ul>
<li>
<h2 class="stackerror">InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
</h2>
<ul>
答案 0 :(得分:1)
同一问题。 Found another example here并通过向AddAuthentication()添加其他选项来修复我的问题:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = "";
}).AddOAuth("", Options => ...);