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);
}
幸福是一件礼物,得到它的秘诀是不怀期待,只在它来的时候尽情享受