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.
Hi @Sachin Prakash ,
How's going today?
We have not heard from you for a long time. Do you have any other questions regarding this issue? If you have any other problems while using SharePoint, you could also reply to this thread directly. We will try our best to help you soon. If it has been resolved, you can enclose it by marking it as anwer.
Best Regards,
Baker Kong