Sharepoint API Authenicaton issue.

Asya Brevdo 21 Reputation points
2020-08-26T22:56:38.567+00:00

We are trying to integrate with Microsoft project online. We cannot use cookies, so we are following https://medium.com/@anoopt/accessing-sharepoint-data-using-postman-sharepoint-rest-api-76b70630bcbf to get authentication token.

We've tried to creating application for access token in both:
https://mycompany.sharepoint.com/sites/pwa/_layouts/15/appregnew.aspx
https://mycompany.sharepoint.com/_layouts/15/appregnew.aspx
and use token accordingly. See difference in paw in url.
However, if we use this base URL , we are getting list without any projects. We do have projects under PWA site.
https://mycompany.sharepoint.com/_api/web/Lists

And if we use this URL, we are getting permission issue.
https://mycompany.sharepoint.com/sites/pwa/_api/web/Lists
{
    "odata.error": {
        "code": "-2147024891, System.UnauthorizedAccessException",
        "message": {
            "lang": "en-US",
            "value": "Access denied. You do not have permission to perform this action or access this resource."
        }
    }
}
We were using it in postman. We are not using .net

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,230 questions
{count} votes

Accepted answer
  1. Amos Wu-MSFT 4,051 Reputation points
    2020-08-27T07:07:46.537+00:00

    If yo want this app to access all the tenant,you need to change the Permission Request XML to this:

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

    The permissions given in the tutorial only allow app access current web site.
    20579-image.png
    More information about add-in permission for your reference:
    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint


2 additional answers

Sort by: Most helpful
  1. Maryna Dobrynina 0 Reputation points
    2023-09-14T07:33:49.44+00:00

    I have the same problem and I changed the Permission Request XML, but the issue is still is.

    {"error":   
    	{"code":"-2147024891, System.UnauthorizedAccessException",
    		"message":
    			{"lang":"en-US",
    			"value":"Access denied."}
    	}
    }
    
    0 comments No comments

  2. Robert McCoy 0 Reputation points
    2023-09-15T13:19:44.0033333+00:00

    Hi.

    I'm having the same issue as Maryna in that we have 2 customer systems we want to give access to SharePoint from Business Central to upload documents but we get the above error.

    0 comments No comments

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.