I'm building a Blazor Server app integrated with Microsoft Teams, and I want to use AuthorizeRouteView to protect certain pages/routes based on Teams authentication.
I found official Microsoft samples, but for some reason there is not a single blazor project, although if create a project in VS, we get a blazor server app
In the Vs blazor template, there's logic to sign in and fetch the user profile like this:
private async Task ShowProfile(){ IsLoading = true; var tokenCredential = await GetOnBehalfOfCredential(); var graph = GetGraphServiceClient(tokenCredential); Profile = await graph.Me.GetAsync(); UserPhotoUri = await GetPhotoAsync(graph); IsLoading = false; ErrorMessage = string.Empty;}private async Task ConsentAndShow(){ try { await teamsUserCredential.LoginAsync(_scope); // popup login NeedConsent = false; await ShowProfile(); } catch (ExceptionWithCode e) { ErrorMessage = e.Message; }}From what I understand, teamsUserCredential.LoginAsync(_scope) triggers a popup (auth-start.html & auth-end.html) and returns an access token for the given scopes.
I want to completely block access to the app unless the user is accessing it from inside Microsoft Teams.
Question:How can I wire up this Teams authentication flow to work with Blazor's built-in AuthorizeRouteView?
Any working examples would be appreciated!