Using CSOM for .NET Standard, and MFA is enabled

贾海锋 306 Reputation points
2021-03-02T12:07:43.283+00:00

i follow this docs for sharepoint online dev
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard
and MFA is enabled in my env
the result of the function : httpClient.PostAsync() is

ValueKind = Object : "{"error":"interaction_required","error_description":"AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000003-0000-0ff1-ce00-000000000000'.\r\n

as far as i know, app password can work in .net framework 4.6.1 with MFA
so my question is how to connect to sharepoint online, which MFA is enabled, based on .net core 3.1 ?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,048 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,150 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2021-03-03T02:12:43.04+00:00

    Hi justin-jia,

    App Password can't be used in .NET Core solution (.NET Framework solution works).

    A workaround is to use Azure AD App-Only credential with PnP.Framework library, here is a blog with the configuration steps and code demo for your reference:

    Calling SharePoint Online APIs using Azure AD App-Only permissions and certificate auth

    Here are some points to note:

    1. It's necessary to create certificate for Azure AD App for authentication, ClientSecret method has been blocked by SharePoint Online currently.
    2. Before installing PnP.Framework, please install PnP.Core with this command firstly:
          Install-Package PnP.Core -Version 0.6.6-beta3
        
           Then install PnP.Framework:
         
         
          Install-Package PnP.Framework -Version 1.2.0
      
    3. The old SharePointPnPCoreOnline is archived and not complicate with .NET Core solution, so please don't use it for MFA Authentication.

    Here is the test result capture in .NET Core solution:

    73592-snipaste-2021-03-03-10-11-54.png

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. 贾海锋 306 Reputation points
    2021-03-03T06:08:25.887+00:00

    hi @Jerryzy-MSFT thanks for your response. it work for me. i have another question, there is only sharepoint permissions, i also need project permissions. will project permissions be available in the future ? ![73599-image.png][1] [1]: /api/attachments/73599-image.png?platform=QnA


  2. 贾海锋 306 Reputation points
    2021-03-03T06:28:32.53+00:00

    hi @Jerryzy-MSFT

    got it

    thanks again

    0 comments No comments