Hi @Sachin Prakash ,
You could consider using App password to overcome the MFA etc.
This password will act as the same role as user password but won't require MFA procedure (dialogue popup).
static void Main(string[] args)
{
string SiteUrl = "https://abc.sharepoint.com/sites/s01";
//var pwd = "userpassword";
var pwd = "gnckrrjmdwvbywtr"; //this is app password!
var username = "support@abc.onmicrosoft.com";
Console.WriteLine("Hello World!");
ClientContext context = new ClientContext(SiteUrl);
SecureString securestring = new SecureString();
pwd.ToCharArray().ToList().ForEach(s => securestring.AppendChar(s));
context.Credentials = new SharePointOnlineCredentials(username, securestring);
var web = context.Web;
context.Load(web);
context.ExecuteQuery();
Console.WriteLine($"web title: {web.Title}");
Console.ReadKey();
}
Best Regards,
Baker Kong
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.