-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Looping redirect with Azure Signalr Service #573
Comments
I update the example repro in the original comment to be based on a project within the microsoft-identity-web repository. The example is a modified version of the BlazorServerCallsGraph test project. Also, the downstreamAPI.CallWebApiForAppAsync() method works and does not cause the endless login looping. This is illustrated in the example. |
@jassent This might be due to the fact because of Graph, the token acquisition is registered as a singleton, however, Blazor can only work with scoped services. This should be a workaround: services.AddTokenAcquisition(false) btw, false is the default. Let us know if this resolves the issue for you. |
Thank you for the suggestion. I appreciate the assistance. I gave it a try and it didn't work for the /showprofile page. No data was returned by the graphclient and no looping redirect occurred. Instead an exception was generated. My hunch is that maybe the Azure SignalR Service doesn't like how Microsoft.Idenetity.Web is modifying the httpcontext? After adding services.AddTokenAcquisition(false) to the startup.cs, "user = await _graphServiceClient.Me.Request().GetAsync();" produces the following exception:
|
|
startup.cs
The project that reproduces the error is based on the "BlazorServerCallsGraph" test included with Microsoft.Identity.Web: |
@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." |
@jassent i am able to repro the issue, will hopefully have an update for you this week. thanks. |
Good luck! You got this! |
@jennyf19 this branch worked! No more looping redirect! The calls to graph return data w/ Azure Signalr Server wired-up. Thank you for the attention, quick turnaround and solution. Would you like me to "close with comment" or is that something you will do? |
@jassent awesome! Thanks for getting back to us. We'll leave it open until the release w/this fix happens, probably end of month. Thanks again. |
@jassent, the fix is available in Microsoft.Identity.Web 1.0.0 |
Which version of Microsoft Identity Web are you using?
Microsoft.Identity.Web (0.4.0-preview)
Where is the issue?
[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.
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)
The text was updated successfully, but these errors were encountered: