简体   繁体   中英

Azure B2C AD / dotnetcore 2.0 MVC app not authorising

I've followed the tutorial at https://blogs.msdn.microsoft.com/webdev/2017/10/17/user-accounts-made-easy-with-azure/#comment-312956 and am reasonably confident that I have set up my Azure B2C Tenant correctly - I have tested the login functionality through the Azure Portal, and all is good.

However, using the demo app, I am unable to sign in. I don't get any errors, and I can see through the browser dev tools that the request goes off to the portal, but it returns almost immediately without giving me the login page, and my app is still in the "sign in" state. Here's a screenshot of the network activity (FirefoxDeveloper)

开发者工具活动

There are no login activities recorded in the B2C portal and there are no errors anywhere...Any help would be gratefully received!

found the problem. The walkthrough for creating the B2C application does not mention that you need to append "/signin-oidc" to the Reply URL

The callback path is set in the OpenIdConnectOptions instance and defaults to "signin-oidc", eg taking the sample code

public void Configure(string name, OpenIdConnectOptions options)
{
    options.ClientId = AzureAdB2COptions.ClientId;
    options.Authority = AzureAdB2COptions.Authority;
    // This is the default value
    options.CallbackPath = "signin-oidc";
    options.UseTokenLifetime = true;
    options.TokenValidationParameters = new TokenValidationParameters() { NameClaimType = "name" };

    options.Events = new OpenIdConnectEvents()
    {
        OnRedirectToIdentityProvider = OnRedirectToIdentityProvider,
        OnRemoteFailure = OnRemoteFailure,
        OnAuthorizationCodeReceived = OnAuthorizationCodeReceived
    };
}

Whatever you set this to, you must align the ReplyUri in your Azure B2C tenant eg

http://myapp.com/signin-oidc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM