OID、网络表单和从 B2C 获取声明

问题描述

我看了又看,但找不到任何可以解决我的问题的方法。我正在尝试使用 ASP Webform 从 B2C 获取索赔信息。我可以获得 B2C 登录,但它在返回时不会触发 AuthorizationCodeReceived 事件。我怀疑这就是为什么我没有得到任何回报。有人可以告诉我下面的代码有什么问题:

    public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseCookieAuthentication(new CookieAuthenticationoptions());

        // Configure OpenID Connect middleware for each policy
        //app.USEOpenIdConnectAuthentication(CreateOptionsFromPolicy(SignUpPolicyId));
        //app.USEOpenIdConnectAuthentication(CreateOptionsFromPolicy(ProfilePolicyId));
        //app.USEOpenIdConnectAuthentication(CreateOptionsFromPolicy(SignInPolicyId));

        app.USEOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationoptions
            {
                // For each policy,give OWIN the policy-specific Metadata address,and
                // set the authentication type to the id of the policy
                MetadataAddress = String.Format(aadInstance,tenant,SignInPolicyId),AuthenticationType = SignInPolicyId,ResponseType = "code id_token",// These are standard OpenID Connect parameters,with values pulled from web.config
                ClientId = clientId,RedirectUri = redirectUri,PostlogoutRedirectUri = redirectUri,Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthorizationCodeReceived = context =>
                    {
                        Debug.WriteLine("Received");

                        context.ProtocolMessage.EnableTelemetryParameters = false;
                        context.ProtocolMessage.ResponseMode = null;

                        return Task.Fromresult(0);
                    },RedirectToIdentityProvider = context =>
                    {
                        Debug.WriteLine("Redirecting to identity provider for sign in..");

                        context.ProtocolMessage.EnableTelemetryParameters = false;
                        context.ProtocolMessage.ResponseMode = null;

                        return Task.Fromresult(0);
                    },},TokenValidationParameters = new TokenValidationParameters
                {
                    NameClaimType = "name",ValidateIssuer = false
                },});
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)