Skip to content

Instantly share code, notes, and snippets.

@vman
Last active December 17, 2021 17:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vman/37bab1e1d700be238011f1de23a3e275 to your computer and use it in GitHub Desktop.
Save vman/37bab1e1d700be238011f1de23a3e275 to your computer and use it in GitHub Desktop.
SharePoint Online: Using CSOM with an account configured with Multi-factor Authentication (MFA)
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;
using System;
namespace CSOMDemo
{
class Program
{
static void Main(string[] args)
{
var authManager = new AuthenticationManager();
var ctx = authManager.GetWebLoginClientContext("https://contoso.sharepoint.com/");
Web web = ctx.Web;
User user = web.CurrentUser;
ctx.Load(web);
ctx.Load(user);
ctx.ExecuteQuery();
Console.WriteLine(web.Title);
Console.WriteLine(user.LoginName);
Console.ReadLine();
}
}
}
@sigomtesting
Copy link

Yes, you must definitely use a Windows Forms project in .NET Framework 4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment