question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Looping redirect with Azure Signalr Service

See original GitHub issue

Which version of Microsoft Identity Web are you using? Microsoft.Identity.Web (0.4.0-preview)

Where is the issue?

  • Web app [X] Sign-in users and call web APIs

Is this a new or an existing app? This is a new app or an experiment.

Repro This sample app demonstrates the bug and uses Microsoft.Identity.Web, Blazor Server, Azure Signalr Service and Microsoft Graph: https://github.com/jassent/Example-Blazor-Graph-Microsoft-Identity-Web/tree/master/tests/BlazorServerCallsGraph

The goal is to add Azure Signalr Service. Adding the following code to startup.cs causes an endless looping redirect when calling Microsoft Graph once the Blazor Server app is using Azure Signalr Service.

services.AddSignalR().AddAzureSignalR();

Expected behavior The expected behavior is to be able to use Microsoft.Identity.Web in a Blazor Server web app that uses Microsoft Azure Signalr Service.

Actual behavior

Build the app and visit: https://localhost:44314/showprofile

Web App works fine when Blazor Server is run self-hosted. Migrating the Web App to Azure Signalr Service causes the problem. Adding “services.AddSignalR().AddAzureSignalR();” to Startup.cs causes the web page calling the Graph Api to continuously reload repeatedly calling https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token

There is an exception thrown in the visual studio debug window but no meaningful information: Exception thrown: ‘Microsoft.Graph.ServiceException’ in System.Private.CoreLib.dll System.Net.Http.HttpClient.Default.LogicalHandler: Information: Start processing HTTP request POST https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token

System.Net.Http.HttpClient.Default.ClientHandler: Information: Sending HTTP request POST https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token

System.Net.Http.HttpClient.Default.ClientHandler: Information: Received HTTP response after 201.8975ms - OK

System.Net.Http.HttpClient.Default.LogicalHandler: Information: End processing HTTP request after 209.1404ms - OK

The browser shows this error in the console window: blazor.server.js:19 [2020-09-12T12:35:54.880Z] Error: Circuit has been shut down due to error.

Graph Api data is returned to the application between each login loop.

Additional context / logs / screenshots Prior versions of the library 0.2.1-preview would produce a different error. The 0.2.1-preview version would allow the web app to call Graph Api, not cause a looping redirect but then would give a system exception (after a successful call to Graph Api) due to a null being returned from _tokenAcquisition.GetAccessTokenForUserAsync(_initialScopes)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
jassentcommented, Sep 14, 2020

@jennyf19, after adding services.AddTokenAcquisition(false); there is no looping redirect. Instead there is this error: “InvalidOperationException: Cannot resolve scoped service ‘Microsoft.Identity.Web.ITokenAcquisition’ from root provider.”

1reaction
jassentcommented, Oct 1, 2020

@jmprieur & @jennyf19, thank you! Will give it a try in the next few days. I appreciate the work and the follow-up communication.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting guide for Azure SignalR Service
This article provides troubleshooting guidance for some of the common issues that customers might encounter.
Read more >
Getting an infinite redirect loop on Azure App Service with ...
tl;dnr In essence, my app was working fine until implementing a shared cookie. Now I have an infinite login redirect loop.
Read more >
Infinite redirect loop to https - appsloveworld.com
I managed to solve this for RC1 using this block of code: app.Use(async (context, next) => { String protoHeader = context.Request.
Read more >
Signalr without authentication. You can use either the primary
Navigate to your SignalR Service in the Azure portal. The following code is an example that uses SignalR and ASP. Net. To enable...
Read more >
Sign-in using multiple clients or tenants in ASP.NET Core and ...
The CustomSignOut is used to sign out the correct schemes and redirect to the Azure AD endsession endpoint. The CustomSignOut method uses ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found