The sign-in name or password does not match one in the Microsoft account system

错误提示:登录的用户名或密码与Microsoft账号不一致(SharePoint O365)
普通的验证方式在这里没用,需要使用MFA的验证方式

static void Main(string[] args)
{
string siteUrl = "https://XXXXXX.sharepoint.com/sites/DocWebTest";
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);
// The obtained ClientContext object can be used to connect to the SharePoint site.
Web web = ctx.Web;
ctx.Load(web, w => w.Title);
ctx.ExecuteQuery();
Console.WriteLine("You have connected to {0} site, with Multi Factor Authentication enabled!!", web.Title);
}

posted @ 2021-03-15 16:38  SelenaZhou  阅读(410)  评论(0编辑  收藏  举报