1
votes

I'm trying to authorize a Xamarin Forms app to communicate with a SignalR hub in a ASP.NET Core Blazor Server app with Azure AD B2C configured. Login functionality in Xamarin Forms as well as in ASP.NET Core Blazor Server app is working fine with Azure AD B2C, but I'm not able to use [Authorize] on SignalR hub. I have tried to pass access token received from Azure AD B2C to HubConnectionBuilder as follows.

connection = new HubConnectionBuilder().
            WithAutomaticReconnect().
            WithUrl(Location + Name, options => { options.AccessTokenProvider = () => Task.FromResult(AccessToken); }).
            Build();
1

1 Answers

0
votes

Adding following to Startup.cs in ASP.NET Core Blazor app solved the issue. I also used this authentication scheme to authorize the SignalR hub.

.AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options));