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

%3CLINGO-SUB%20id%3D%22lingo-sub-1055671%22%20slang%3D%22en-US%22%3EHow%20to%20automate%20the%20connection%20to%20a%20SharePoint%20site%20with%20multi%20factor%20automation.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1055671%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20trying%20to%20organize%20an%20Azure%20Development%20Pipeline%20where%20the%20deployment%20and%20some%20development%20process%20would%20be%20automated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20SharePoint%20sites%26nbsp%3B%20we%20are%20currently%20working%20with%20require%20a%20multi-factor%20authentication%2C%20which%20mean%20the%20site%20access%20requires%20confirmation%20from%20either%20the%20phone%20up%20or%20the%20security%20code%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPreviously%20in%20the%20code%20the%20following%20connection%20logic%20used%20to%20work%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22pln%22%3E%26nbsp%3Bcontext%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ECredentials%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3ESharePointOnlineCredentials%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22pln%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EConfigSettings%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAdminUserName%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22pln%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EConfigSettings%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAdminPassword%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EThis%20code%20no%20longer%20works%20as%20this%20code%20cannot%20connect%20to%20the%20multi%20factor%20authentication%20sites%20and%20a%20different%20code%20is%20used%20to%20connect%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22kwd%22%3Evar%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20authManager%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EOfficeDevPnP%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ECore%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAuthenticationManager%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Econtext%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20authManager%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetWebLoginClientContext%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EConfigSettings%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ESiteUrl%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EThis%20code%20works%20well%20when%20the%20code%20is%20run%20manually.%20When%20this%20code%20is%20reached%2C%20the%20connection%20interface%20opens%20and%20the%20credentials%20are%20handled%20and%20confirmed.%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20are%20the%20ways%20to%20automate%20the%20authentication%20process%3F%20Can%20the%20multi-factor%20authentication%20be%20fully%20automated%20using%20some%20sort%20of%20secure%20token%3F%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20your%20answers%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional 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(
 ConfigSettings.AdminUserName,
 ConfigSettings.AdminPassword);

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