Search code examples
oauthazure-active-directoryazure-ad-graph-apisharepoint-rest-api

Using SharePoint Rest API


I am trying to read SharePoint lists using the following endpoint (http://url/_api/web/lists) and I am passing the access token, but the response returns Access Denied.

While I use the same access token to call an endpoint from the graph API (https://graph.microsoft.com/v1.0/sites/root/lists) and it works fine.

Should I use a different access token when I work with SharePoint REST APIs? or am I missing something here?

Thanks.


Solution

  • Yes, you should use a different access token since the endpoints are different. The graph api and sharepoint api are different resource, you need to grant the application different permissions.

    enter image description here

    Note:

    SharePoint APIs are available via the Microsoft Graph API. You may want to consider using Microsoft Graph instead.