How to automate the connection to a SharePoint site with multi factor automation for Azure Development Pipiline

Mikhail 41 Reputation points
2019-12-09T16:49:06.797+00:00

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)

    
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    
    
    
    
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,752 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. FrankHu-MSFT 976 Reputation points
    2019-12-11T02:32:41.903+00:00

    Hello,

    The multi factor authentication cannot be automated, as a large point of the multi factor is to provide secure authentication from a human that is logging in with multiple points of security from said human to prove their identity.

    Perhaps you could utilize a different authentication protocol, such as providing the sharepoint server a service principal that has exclusive access to your azure development pipeline.
    If your azure dev pipeline is utilizing AAD OAuth2 you would be able to utilize the AAD Client Credential flow. https://learn.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow

    Note per the post below, for further help on this azure devops pipeline authentication question please open a developer community item with the tag [AltCreds] in the title. For faster service, please search for [AltCreds] in the developer community forum first, as your question might already be answered. You can reach out to us on Twitter at @Azure Dev Ops too.
    https://devblogs.microsoft.com/devops/azure-devops-will-no-longer-support-alternate-credentials-authentication/

    Reference Links : https://developercommunity.visualstudio.com/spaces/8/index.html
    https://twitter.com/AzureDevOps

    Please remember to mark one of the responses as answer if your question has been answered. If not please let us know if there are anymore questions.

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.