Blazor WASM Connection using ConfidentialClientApplicationBuilder

Viewed 95

I am trying to implement a call to an existing Azure Service using ConfidentialClientApplicationBuilder in Blazor WASM. I am getting an 'Operation is not supported on this platform.' error when I try to get a Token using the ExecuteAsync() command. Is there another way to get a token or a way to get past the ExecuteAsync() command?

private async Task<string> GetToken()
    {
        var app = ConfidentialClientApplicationBuilder.Create(ClientId)
       .WithClientSecret(ClientSecret)
       .WithAuthority(new Uri(AADInstance+"/"+Tenant))
       .Build();

        string[] scopes = new string[] { AADInstance + ".default" };

        AuthenticationResult result = null;
        try{
            AcquireTokenForClientParameterBuilder builderResult = app.AcquireTokenForClient(scopes);
            var token = await builderResult.ExecuteAsync(); 
        }

}

1 Answers

This isn't possible in Blazor WASM as far as I know and it will also cause to leak your ClientSecret to the users of your wasm app. Because all runs in the browser of the user.

Related