Use Microsoft Graph in a web API with a Blazor Server client

Bradley Plett 36 Reputation points
2021-04-04T08:29:52.687+00:00

Whereas I have spent a very long day trying and failing to get this working, I do feel like I'm tantalizingly close. In fact I have this example working. The problem is that example uses a WPF client, and for the life of me I can't seem to get the same functionality working in a Blazor Server app.

Here is my scenario: I have a .NET Core 3.1 web API service (i.e. a "Microsoft.AspNetCore.Mvc.ApiController" based on "Microsoft.AspNetCore.Mvc.ControllerBase"). I have a "Blazor Server" client app that is successfully calling the endpoints in the service. I am using Azure AD B2C for authentication, and both of these apps are registered in the same tenant. Everything is working EXCEPT using Microsoft Graph. When I try to use Graph I get a "Microsoft.Identity.Client.MsalServiceException" - "unsupported_grant_type".

I'm stumped. I realize I haven't supplied enough information for anyone to solve the problem, but I don't know Azure B2C / OAuth nearly well enough, so be gentle with me, but ask whatever clarifying questions are necessary.

Thanks a lot in advance!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,346 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,479 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,742 questions
{count} votes