Hi @Suresh S ,
With MFA enabled, the method using class SharePointOnlineCredentials with username and password for authentication would not work.
You have only two options:
- Use user credentials with the OTP prompt or call. This needs to install the package SharePointPnPCoreOnline: https://www.nuget.org/packages/SharePointPnPCoreOnline. var authManager = new OfficeDevPnP.Core.AuthenticationManager();
// This method calls a pop up window with the login page and it also prompts
// for the multi factor authentication code.
ClientContext ctx = authManager.GetWebLoginClientContext(siteUrl);
2.Use app-only for authentication: https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
If an Answer is helpful, please click "Accept Answer" and upvote it. Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.