Having trouble to understand what going on and I really could use some thoughts and inputs. Please, I am not very good at describing in text what is the problem, so be gentle.
I have a Blazor wasm frontend and a Azure Function backend.
I do a standard, nothing special, Azure AD login.
Later in code, I connect with the AzFunction using the bearer token, and it works. The AzFunction evaluates the token and identifies the user for further processing. I should mention that the AzFunction connects to Graph and other APIs.
So everything is fine and working, here is my problem.
I want to connect to the AzFuntion at login time, to get some user profile information. For debugging I simply made a button, and again, everything works.
Then I moved "the button code" to a method called by RemoteAuthenticatorView OnLogInSucceeded, in Authenticator.razor.
<RemoteAuthenticatorView Action="@Action" LogInFailed="LogInFailedFragment" OnLogInSucceeded="LoginComplete" />
Here is my problem: Using the OnLogInSucceeded I get 2 Azure AD logins that I have to respond to. After the first one, It goes directly to the second. All simply because I moved the code from a button to OnLogInSucceeded. When I debug, I clearly see that the token is present before it connects to AzFunction.
Also, when I set a breakpoint in visual studio at the LoginComplete function called from OnLogInSucceeded, and just holds it for a few seconds, it goes throught the login process with just one login dialog.
Could anyone please help me understand why?
Any pointers on a better please to put the "get User profile" code? What I need is the code to run, so when the login is completed, the user profile info is retrived, with just one login.
Edit:
The code seem to have a better solution, however I still do not understand what made the second login to apper... And that was kind of the main reson for my question.