Open mr-nuno opened 2 years ago
Now I get the following
System.ArgumentNullException: Value cannot be null. (Parameter 'module')
at Blazorade.Core.Interop.DotNetInstanceCallbackHandler`2[[Blazorade.Msal.Security.AuthenticationResult, Blazorade.Msal, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null],[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(IJSObjectReference module, String functionIdentifier, Dictionary`2 data)
at Blazorade.Core.Interop.DotNetInstanceCallbackHandler`1[[Blazorade.Msal.Security.AuthenticationResult, Blazorade.Msal, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null]]..ctor(IJSObjectReference module, String functionIdentifier, Dictionary`2 data)
at Blazorade.Msal.Services.BlazoradeMsalService.AcquireTokenSilentAsync(TokenAcquisitionRequest request)
at Blazorade.Msal.Services.BlazoradeMsalService.AcquireTokenAsync(TokenAcquisitionRequest request)
at Blazorade.Msal.Services.BlazoradeMsalService.AcquireTokenAsync(String loginHint, IEnumerable`1 scopes, Boolean fallbackToDefaultLoginHint, Nullable`1 prompt)
This is when I try to call AcquireTokenAsync
Thanks for reporting! I'll start looking into this.
Just a few initial questions:
BlazorWasmSample
application?InteractiveLoginMode.Redirect
to InteractiveLoginMode.Popup
?Thanks for reporting! I'll start looking into this.
Just a few initial questions:
- Do you get the same error / problem when trying to run the
BlazorWasmSample
application?- Do you still get the problem if you try to switch the interactive login mode from
InteractiveLoginMode.Redirect
toInteractiveLoginMode.Popup
?
No error. The wasm example is working fine Yes, popup works just fine but in that case you never land on the redirect page.
If I skip the LoginRedirectHandler
component I got it work with this solution.
This in MainLayout
var loginHint = await _msalService.GetDefaultLoginHintAsync();
if (string.IsNullOrEmpty(loginHint))
{
await _msalService.AcquireTokenAsync();
}
else
{
await _msalService.AcquireTokenAsync(loginHint: loginHint);
}
And changed redirect uri in Azure app to /
and skipped the separate SignedIn
view.
But it feels like you could end up in a redirect loop with this solution. If AcquireTokenAsync
cant find a cached token it will send you on a endless login loop.
I remember having similar issues when I was working on the sample applications. I just can't remember what those issues exactly were.
I'll see if I can repro your problem with your original setup. Blazorade MSAL should definitely work with both server and WASM applications, and both redirect and popup interaction modes. Personally, I prefer the popup mode, because the user does not lose the context as easily as might happen when redirecting back and forth. Still, redirecting is fully supported in MSAL, so it should be fully supported also in Blazorade MSAL.
I'll look into this.
net6
v2.1.0
and2.2.0
ofBlazoradeMsal
Expected authentication flow:
MainLayout
withAcquireTokenAsync
https://localhost:5001/signin-redirect
OnLoginSucceeded
navigate to startpageOnLoginFailed
show errorI'm using the
LoginRedirectHandler
component on my redirect uri in my application. In my casehttps://localhost:5001/signin-redirect
. When I add theLoginRedirectHandler
to that page i seems to process the redirect data from Azure AD but it doesn't get theOnLoginSucceeded
or theOnLoginFailed
event. It just process the query data from the provider and stops. Without errors. The login is succesful because I have all the token information in my local storage.If I try to use the
HandleRedirectPromiseAsync
in mysignin-redirect
page it doesnt seem to process the provider data from the redirect. Or sometimes end up in a redirect loop with a error message saying that you couldnt be logged in.