Skip to content

Blazor WebAssembly Msal TryAddAdditionalParameter("prompt", "select_account") does nothing #44854

Closed
@juho-hanhimaki

Description

@juho-hanhimaki

Description

I am using the MSAL authentication with Azure AD trying to add prompt parameter to the sign in. It does not work as expected.

The observed request https://login.microsoftonline.com/common/oauth2/v2.0/authorize?... doesn't contain the prompt parameter and the request just completes with SSO.

Reproduction Steps

RedirectToLoginSelectAccount.razor

@using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
@inject NavigationManager Navigation

@code {
    protected override void OnInitialized()
    {
        var requestOptions = new InteractiveRequestOptions()
            {
                Interaction = InteractionType.SignIn,
                ReturnUrl = Navigation.Uri,
            };

        requestOptions.TryAddAdditionalParameter("prompt", "select_account");

        Navigation.NavigateToLogin("authentication/login", requestOptions);
    }
}

The following weird version works on development build in VS, but doesn't work in published release build.

        var extraQueryParametersDictionary = new Dictionary<string, string> { ["prompt"] = "select_account" };
        requestOptions.TryAddAdditionalParameter("extraQueryParameters",
            JsonSerializer.Deserialize<JsonElement>(JsonSerializer.Serialize(extraQueryParametersDictionary)));

Expected behavior

Authentication to include the prompt parameter.

Actual behavior

Prompt parameter missing.

Regression?

No response

Known Workarounds

No response

Configuration

7.0.101 [C:\Program Files\dotnet\sdk]

<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-rtm.22512.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-rtm.22512.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="7.0.0-rtm.22512.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0-rtm.22511.4" />

Other information

No response

Metadata

Metadata

Assignees

Labels

Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-blazorIncludes: Blazor, Razor Componentsfeature-blazor-msalThis issue is related to MSAL usage in Blazorfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblyfeature-blazor-wasm-authinvestigate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions