Forum Discussion

Lance Alcabasa's avatar
Lance Alcabasa
Copper Contributor
Aug 27, 2021

Connect to SharePoint Online with MFA using CSOM

I have the CSOM code below for trying to connect to SharePoint Online with MFA enabled:

 

 

$SiteUrl = "http://our-tenant.sharepoint.com"

#Setup Authentication Manager
$AuthenticationManager = new-object OfficeDevPnP.Core.AuthenticationManager
$Ctx = $AuthenticationManager.GetWebLoginClientContext($SiteUrl)
$Ctx.Load($Ctx.Web)
$Ctx.ExecuteQuery()

 

 

I am encountering the following error: 

 

Error: Cannot find type [OfficeDevPnP.Core.AuthenticationManager]: verify that the assembly containing this type is loaded

 

 

I already have PnP SharePoint installed via "Install-Module PnP.PowerShell" so I am not sure what is wrong. For reasons, I cannot use the Connect-PnPOnline cmdlet.

 

How do I connect to SharePoint Online with CSOM if my account has MFA?

Resources