Access SharePoint Online with AzureAD APP authentication from .Net core 3.1 Console application

Károlyi Zoltán 26 Reputation points
2021-02-22T17:21:04.01+00:00

Hi Masters,

In a new solution we need to access SharePoint Online Site with CSOM. The application is .net Core 3.1 based, and we have to user AzureAD to access SharePoint. So I have created an App (App Registration) in Azure, created a Client Secret, and get AccessToken from AAD.

But SharePoint Online sends 401 back.

Using ClientCertificate to get AccessToken the connection is working.

Is there a way to use ClientSecret to access SharePoint?

Regards,
Zoli

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,403 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,301 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,631 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2021-02-23T01:53:43.39+00:00

    Hi @KrolyiZoltn-0660 ,

    Currently, Azure AD App Client Secret authentication option is blocked by SharePoint Online, so it's not available to use Client Secret, it's necessary to use Certificate instead:

    70873-snipaste-2021-02-23-09-49-37.png

    Please check the official documetation for detailed information:

    Granting access via Azure AD App-Only

    And here is a demo to get acess token with Azure AD App Certificate in CSOM, I suggest that you can refer :

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

    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

0 additional answers

Sort by: Most helpful