Connect to SharePoint Online with MFA using CSOM

Occasional Contributor

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?

1 Reply
The latest iteration of the PnP.PowerShell module no longer includes this. You can try and replace "OfficeDevPnP.Core.AuthenticationManager" with "PnP.Framework.AuthenticationManager" instead.