在重定向URI(MVC控制器)中获取身份令牌(id_token)

问题描述 投票:0回答:1

我希望这与Okta(我们用于社交登录的服务)大多是不可知的,但我很难找到文档。我正在使用.NET Core 2.0+,我的Startup.cs看起来像这样:

services.AddAuthentication(options =>
    {
        options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
    })
    .AddCookie()
    .AddOpenIdConnect(options => 
    {
        //Configuration pulled from appsettings.json by default:
        options.ClientId = Configuration["okta:ClientId"];
        options.ClientSecret = Configuration["okta:ClientSecret"];
        options.Authority = Configuration["okta:Issuer"];
        options.CallbackPath = "/authorization-code/callback";
        options.ResponseType = OpenIdConnectResponseType.IdToken;
        options.SaveTokens = true;
        options.UseTokenLifetime = false;
        options.GetClaimsFromUserInfoEndpoint = true;
        options.Scope.Add("openid");
        options.Scope.Add("profile");
        options.Scope.Add("email");
    });

站点内的登录表单允许您单击“登录Facebook”,并通过身份提供程序进行身份验证过程。确认后,它会回到我定义的重定向'Home / Secure'。重定向返回时,id_token在URL中作为锚点:

https://localhost:5001/Home/Secure#id_token=XXXXXXX

我还可以通过Chrome开发人员工具控制台获得一个授权调用,该调用可以通过其中的id_token获得响应。我对.NET Core并不熟悉,所以我很难理解如何抓住这个id_token。

请求似乎没有Query或QueryString参数中的id_token,所以我没有看到我可以抓住它的位置。

c# asp.net-core oauth-2.0 claims-based-identity okta
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.