我已按照https://developer.okta.com/quickstart/#/okta-sign-in-page/dotnet/aspnetcore中的确切步骤进行操作
这是我的 Startup.cs 中的内容
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OktaDefaults.MvcAuthenticationScheme;
})
.AddCookie()
.AddOktaMvc(new OktaMvcOptions
{
OktaDomain = "https://domain.oktapreview.com",
ClientId = "xxxxxxxxxxxxxxxxxxx",
ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
});
Run Code Online (Sandbox Code Playgroud)
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAuthentication();
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
我已经使用 OpenID Connect强文本在 OKTA 中创建了该应用程序。当我启动应用程序时出现以下错误
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden]'.
Run Code Online (Sandbox Code Playgroud)
当我 ping https://domain.okta.com/oauth2/defau/v1/keys时 出现以下错误
{"errorCode":"E0000006","errorSummary":"You do not have permission to perform the requested action","errorLink":"E0000006","errorId":"oaeX0BPGXjlQ4qE1emo_gDk4w","errorCauses":[]}
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用 OKTA 进行身份验证 OKTA 如何知道哪个用户正在尝试进行身份验证?
试试这个:将 OktaMvcOptions.AuthorizationServerId 设置为空字符串
.AddOktaMvc(new OktaMvcOptions
{
OktaDomain = "https://domain.oktapreview.com",
ClientId = "xxxxxxxxxxxxxxxxxxx",
ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AuthorizationServerId = String.Empty
});,
Run Code Online (Sandbox Code Playgroud)
连接到 okta 开发帐户时不需要执行此操作,但切换到生产帐户时需要执行此操作。
如果这没有帮助,请设置 IdentityModelEventSource.ShowPII 为您提供更详细的错误消息:
public void ConfigureServices(IServiceCollection services)
{
IdentityModelEventSource.ShowPII = true;
....
Run Code Online (Sandbox Code Playgroud)
这帮助我弄清楚了第一个建议,因为它向我显示了客户端试图访问的 URL,并且我发现 URL 中有一个意外的“/default”。