Using B2C AD User Store with Blazor - Stuck in infinite Loop

Viewed 122

I am trying to get my Core5 Blazor server app to play nicely with Azure B2C user store. I have created a new project and chosen individual user accounts from cloud.

After the wizard I am left with this in my appsettings.json

"AzureAdB2C": {
"Instance": "https://myinstancename.b2clogin.com",
"ClientId": "5cdf4fxx-0500-xxxx-xxxx-fadfa8672xxx",
"CallbackPath": "/signin-oidc",
"Domain": "mytenantname.onmicrosoft.com",
"SignedOutCallbackPath": "/signout/B2C_1_susi",
"SignUpSignInPolicyId": "B2C_1_SignUpIn",
"ResetPasswordPolicyId": "B2C_1_PwReset",
"EditProfilePolicyId": ""

},

In Azure I have created a new app registration and given it a redirect url of https://localhost:44349/ which is what my app is running locally from visual studio.

IN the B2C setup I have created user flows from the default templates and recorded those in my appsettings.json (as shown in the config above).

When I fire up my application I am getting stuck in a loop. The title in the browser goes in an infinite loop between logging in and myinstancename.b2clogin.com/mytenantname.onmicrosoft.com/B2C_1_SignUpIn/oauth/authorize? . Can anyone give any points on where I might have gone wrong here??

1 Answers

I think the problem is the redirect URL. From MS doc: Set the Redirect URI drop down to Single-page application (SPA) and provide the following redirect URI: https://localhost:{PORT}/authentication/login-callback. The default port for an app running on Kestrel is 5001. If the app is run on a different Kestrel port, use the app's port. For IIS Express, the randomly generated port for the app can be found in the Server app's properties in the Debug panel. Since the app doesn't exist at this point and the IIS Express port isn't known, return to this step after the app is created and update the redirect URI. A remark appears in the Create the app section to remind IIS Express users to update the redirect URI.

Now you need to implement the login-callback endpoint

Related