0
votes

On a project, I'm using app-only tokens and Graph API to perform various operations on data in Office 365 (this is how the app is registered). When it comes to SharePoint, certain operations are not available through the Graph API but are available through SharePoint REST API.

My question is: is there a way to use Graph API tokens with SharePoint REST API?

The closest answer I could find is this:

To access the http:///site/_api/lists endpoint, Graph API token wont work.

Taken from here.

However, the answer is about a specific endpoint and is pretty old, so I wonder whether this is (still) true.

Update

Here's how I'm calling the various endpoints.

1

1 Answers

3
votes

The token you are using to access the graph is in fact an azure active directory token. Lots of other APIs accept those in office 365. The procedure is more or less the same expect instead of selecting the Microsoft graph API when requesting the scopes, you have to select the SharePoint API. Also note that some actions (mostly the tenant related things) do require you to present a token generated with a client id + certificate and not client id +secret.

EDIT: if you are using AAD v2 endpoints the requested scope has to be https://tenantName.sharepoint.com/.default when requesting an access token for SharePoint REST API