Connecting from desktop app to SharePoint online

Dariusz Roszak 1 Reputation point
2022-12-29T10:06:19.493+00:00

We created a small desktop app (in c#) which reads and writes lists from SharePoint site, and it worked fine. But once we moved to SharePoint Online we can't connect with this SharePoint site. We get 401 UNAUTHORIZED message. We connect thru Graph API. What type of permissions we need to request and configure in this application?

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,256 Reputation points
    2022-12-30T02:17:09.827+00:00

    Hi @Dariusz Roszak ,

    According to my research and testing, we need to request one of the following permissions in this application: Sites.Read.All, Sites.ReadWrite.All, and the Permission type is ** Application **:

    274992-01.png

    More information for reference:
    Working with SharePoint sites in Microsoft Graph
    Get a site resource

    Hope it can help you. Thanks for your understanding.


    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.



  2. Dariusz Roszak 1 Reputation point
    2023-01-02T10:04:36.403+00:00

    Dear Tong Zhang_MSFT,

    thank you for the answer. We are analyzing it and will be back with confirmation of more questions.


  3. Dariusz Roszak 1 Reputation point
    2023-01-12T15:58:45.6633333+00:00

    Dear Tong Zhang_MSFT,

    thank you for the response. It is really helpful. I am a little confused of permission type ‘application’ for mentioned desktop type app. Is the ‘Delegated (work or school account)’ permission would be also appropriate for our purpose, or ‘Application’ is the only option?

    0 comments No comments

Your answer

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