Share via

C# MSGraph API Sharepoint get Sites list

Georgius 25 Reputation points
2024-11-13T11:30:01.8833333+00:00

Hello,

Need to get sharepoint site content using MS Extra DI login;

I use two way to authenticate on azure Sharepoint site and get sites list:

  1. Using TenantId/ClientId/ClientSecret,
  2. Using MS Extra ID - login form is shown using 2 factor authentication

In first case code works ok and all sites, folders and documents are fetched;

In Second case system returns "Access denied" error on call of method:

await GraphClient.Sites.GetAllSites.GetAsync()

after successfull login via MS Extra ID form.

I use same user to login as it is used in web login in azure portal.

All neccassary permissions are granted.

Thank you in advanced.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-11-14T06:57:31.0066667+00:00

    Hello Georgius,

    Thank you for reaching out to Microsoft Support!

    According to the documentation, when you get all sites list for Sharepoint through the Graph API, the endpoint does not support delegated permissions, only Application permissions, so when you log in with an Extra ID, Access to the endpoint will be denied as an "Access denied" error because it is not supported. So, use Application permissions instead, see the documentation for details.

    User's image

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    Was this answer helpful?


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.