Sharepoint unauthorized access with PnP and SSO token

Michal Banachiewicz 1 Reputation point
2022-10-14T13:23:15.433+00:00

Hi,

I need to develop a SharePoint WPF app that will upload and download files into Office 365 SP.
It needs to use SSO as we need to know who was doing the changes and have best security control.
I am stuck this is what I got:

  1. Azure AD App set up:

250410-image.png

  1. App registered on the site:
    250523-image.png
  2. The simplest C# code to do the call sharepoint API:

250541-image.png

  1. And the result:

250440-image.png

Why?

What am I missing?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,565 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,655 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 30,906 Reputation points Microsoft Vendor
    2022-10-24T06:57:23.91+00:00

    Hi @Michal Banachiewicz
    You will need application type permission to retrieve access token by C# code. Please refer to following permission

    253417-image.png


    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.