-2147024891, System.UnauthorizedAccessException occur when i use rest api to access SharePoint documents

Qingbo Meng 20 Reputation points
2024-08-01T08:17:34.5233333+00:00

Hi Everyone,

I've created a SharePoint app that I am planning to use in order to retrieve a list of documents from the entire tenant. and i have read success about this category
User's image

but when i use the same token access another filed, which in another group, it response 403 error code:
User's image

i did not find a place to set the authority about group.

pls help me find out the root cause ,thanks!

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

Accepted answer
  1. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2024-08-02T02:22:33.7433333+00:00

    Hi @Qingbo Meng ,

    As the message, you should check the permission of your app. Your app might only have permission to one of the site. You should register a new app for the other site. Please refer to following document

    https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

    In your case, you could use the following xml

    <AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" /> </AppPermissionRequests>
    
    
    

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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