Last active
December 17, 2021 17:41
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
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
Did this solve after changing the .net framework from .net core? Have you developed this in Web or Windows App?