microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

[BUG] Mgt login runs after page load

Open Banda943224 opened this issue 1 year ago • 8 comments

I have been using mgt login but this always go to login after main page loads in .Net CORe web application.

I am importing the modules in html head but still no luck.

how can we call login method before the main/index page loads?

Banda943224 avatar Jul 14 '24 00:07 Banda943224

@Banda943224 could you provide us with a small reproduction of your project or some code samples of how you're using mgt?

musale avatar Jul 16 '24 07:07 musale

import { registerMgtComponents, Providers, Msal2Provider, ProviderState } from 'https://unpkg.com/@microsoft/mgt@4'; Providers.globalProvider = new Msal2Provider({ clientId: XXXXXXXXXXXXXX', scopes: ['User.ReadBasic.All', 'User.Read.All', 'User.Read'], tenantid: "XXXXXXXXXXXXX", redirecturi: "XXXXXXXXXXXX", authority: "https://login.microsoftonline.com/XXXXXXXXXXXXXXX", isIncrementalConsentDisabled: true }); registerMgtComponents(); Providers.globalProvider.setState(ProviderState.SignedIn);

Am using above code in my asp.net core layout page.. in the head.. this is executing after the page load, which is concerning as MFA should be done first and then load the website page.

Can you please help me with it?

Banda943224 avatar Jul 16 '24 09:07 Banda943224

can you please create a complete repro that we can run without needing to create a web app etc. our staffing on this project is limited and everything you can do to help us understand your problem help us help you

gavinbarron avatar Jul 18 '24 21:07 gavinbarron

I couldn't create the repo. but here is what I am doing.

  1. I have ASP.Net Core web application
  2. I would like to show the signed in user pic on the top of the web site
  3. Hence, I added mgt-person component
  4. I am currently using PCKE authentication method
  5. I am able to complete the auth method
  6. However, mgt-person component is not being initialized
  7. I have to forcefully use "Providers.globalProvider.login();" method to do this. but this is causing in redirecting/logging in webpage again and again
  8. I am stuck with this since long time.
  9. I have provided the code am using above

need ur help in fixing this. let me know if we can have quick call so that I can explain better if am not able to here.

Banda943224 avatar Jul 28 '24 17:07 Banda943224

@Banda943224 When creating mgt-person component, have you passed in the logged in user id to it? You can share a screenshot of this part of your app here if that's ok.

musale avatar Aug 05 '24 12:08 musale

I am using above statement

Banda943224 avatar Aug 05 '24 13:08 Banda943224

Any update on this?

Banda943224 avatar Aug 27 '24 12:08 Banda943224

@Banda943224 we haven't been able to reproduce this currently, is there a reproduction you can share?

Mnickii avatar Aug 28 '24 11:08 Mnickii

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.