Forum Discussion
Sharepoint online CSOM error
Hello,
I've been trying this simple CSOM code:
string siteCollectionUrl = "https://ieszambia.sharepoint.com/"; string userName = "mailto:email address removed for privacy reasons"; string password = "Put00745"; // Namespace: Microsoft.SharePoint.Client ClientContext ctx = new ClientContext(siteCollectionUrl); // Namespace: http://system.security/ SecureString secureString = new SecureString(); password.ToList().ForEach(secureString.AppendChar); // Namespace: Microsoft.SharePoint.Client ctx.Credentials = new SharePointOnlineCredentials(userName, secureString); // Namespace: Microsoft.SharePoint.Client Site site = http://ctx.site/; ctx.Load(site); ctx.ExecuteQuery(); return View(site.Url.ToString());
and I keep getting the following error: the sign-in name or password does not match one in the microsoft account.
Even though I can log into sharepoint using those same credentials. ITs driving me crazy, what am I doing wrong?
spaieszambiacom
Mhm.... i normally use the "PnP.Framework" Library and this code
SecureString securePassword = new NetworkCredential("", password).SecurePassword;PnP.Framework.AuthenticationManager auth = new PnP.Framework.AuthenticationManager(username,securePassword);ClientContext ctx = auth.GetContext(siteUrl);
4 Replies
spaieszambiacom If multi-factor authentication (MFA) is enabled for this user account, use M365 app password instead of normal password.
Check below threads for more information:
- Use App Password to Authenticate with PowerShell PnP
- Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- spaieszambiacomCopper ContributorHi ganeshsanap,
Thank you for your quick response. Thats thing. MFA is actually disabled. Thats why itsdriving me crazy. Do you have any other suggestions?
Kind Regards- SvenSieverdingBronze Contributor
spaieszambiacom
Mhm.... i normally use the "PnP.Framework" Library and this code
SecureString securePassword = new NetworkCredential("", password).SecurePassword;PnP.Framework.AuthenticationManager auth = new PnP.Framework.AuthenticationManager(username,securePassword);ClientContext ctx = auth.GetContext(siteUrl);