Warm tip: This article is reproduced from serverfault.com, please click

Error on loading request B2C login screen on Blazor WebAssembly app

发布于 2020-11-28 15:46:41

I have followed this tutorial to add authorization and authentication to my WebAssembly app using Azure AD B2C. https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory-b2c?view=aspnetcore-5.0

I have done the tutorial, and done no extra adjustment to the code. However, i am facing an issue when trying to login when running the app.

The resource is not working because the URL the app is using is wrong. It uses this: https://easytimeslot.b2clogin.comeasytimeslot.onmicrosoft.com/b2c_1_customuserflow/v2.0/.well-known/openid-configuration

Instead of using this: https://easytimeslot.b2clogin.com/easytimeslot.onmicrosoft.com/b2c_1_customuserflow/v2.0/.well-known/openid-configuration

Now what have i tried so far to fix it. I tried editing the appsettings.json file, and adding a trailing slash to the Instance and i tried a starting slash in the Domain. None of the them worked.

I also tried looking through the code for the URL, but couldn't find anything.

Does anyone know what i can do to solve this? Thank you in advance!

Questioner
jokk
Viewed
11
jokk 2020-11-29 02:35:38

I figured it out. I was right about the trailing slash in the appsettings.json, however it didn't work editing manually in the file. Therefore i created the project again like so: dotnet new blazorwasm -au IndividualB2C --aad-b2c-instance "{AAD B2C INSTANCE}" --api-client-id "{SERVER API APP CLIENT ID}" --app-id-uri "{SERVER API APP ID URI}" --client-id "{CLIENT APP CLIENT ID}" --default-scope "{DEFAULT SCOPE}" --domain "{TENANT DOMAIN}" -ho -o {APP NAME} -ssp "{SIGN UP OR SIGN IN POLICY}"

Where {AAD B2C INSTANCE} needs to have a trailing slash at the end. For example: https://contoso.b2clogin.com/