How to automate the connection to a SharePoint site with multi factor automation.

Brass Contributor

We are trying to organize an Azure Development Pipeline where the deployment and some development process would be automated.


The SharePoint sites  we are currently working with require a multi-factor authentication, which mean the site access requires confirmation from either the phone up or the security code


Previously in the code the following connection logic used to work

 context.Credentials = new SharePointOnlineCredentials(

This code no longer works as this code cannot connect to the multi factor authentication sites and a different code is used to connect

var authManager = new OfficeDevPnP.Core.AuthenticationManager();context = authManager.GetWebLoginClientContext(ConfigSettings.SiteUrl)

This code works well when the code is run manually. When this code is reached, the connection interface opens and the credentials are handled and confirmed. 

But are the ways to automate the authentication process? Can the multi-factor authentication be fully automated using some sort of secure token?

Thank you in advance for your answers

0 Replies