Hi @Jack Le
Per my research, AuthenticationManager
has depatched GetWebLoginClientContext
. I will recommend you to use SharePoint app only to connect SharePoint Online with MFA. We need to connect SharePoint without using the PnP Framework library. So you can refer to the following code
using Microsoft.SharePoint.Client;
using System;
namespace AzureACSAuth
{
class Program
{
static void Main(string[] args)
{
string siteUrl = "https://contoso.sharepoint.com/sites/demo";
//Get the realm for the URL
string realm = TokenHelper.GetRealmFromTargetUrl(new Uri(siteUrl));
//Get the access token for the URL.
string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, new Uri(siteUrl).Authority, realm).AccessToken;
//Create a client context object based on the retrieved access token
using (ClientContext cc = TokenHelper.GetClientContextWithAccessToken(siteUrl, accessToken))
{
cc.Load(cc.Web, p => p.Title);
cc.ExecuteQuery();
Console.WriteLine(cc.Web.Title);
}
}
}
}
And the app.config should be like following
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- Use AppRegNew.aspx and AppInv.aspx to register client id with secret -->
<add key="ClientId" value="[Your Client ID]" />
<add key="ClientSecret" value="[Your Client Secret]" />
</appSettings>
</configuration>
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.