Skip to content

Blazor WASM Authentication - TryGetToken is null - Version 3.2.0-preview2.20160.5 #19998

@aletc1

Description

@aletc1

Describe the bug

Using MSAL (With Azure Active Directory), after a successful login (when calling AuthenticationService.RequestAccessToken, the method tokenResult.TryGetToken(out var token) returns a null token value.

To Reproduce

Just generate a new MSAL project using:

dotnet new blazorwasm -au SingleOrg --client-id "{CLIENT ID}" --tenant-id "{TENANT ID}"

And to reproduce, consider the following code in index.razor

@code {

    protected override async Task OnInitializedAsync()
    {
        var tokenResult = await AuthenticationService.RequestAccessToken();
        
        if (tokenResult.TryGetToken(out var token))
        {
            if (token == null)
                throw new Exception("Access token is null. BUG?");
        }
    }
}

token shouldnt be null, since was successfully authenticated.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor Componentsfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions