1

Is it possible to authenticate to Sharepoint Online REST API with Azure AD application v2.0 authentication? If yes, which scope should I use for requesting my permissions. Now (for MS Graph API usage) I request "https://graph.microsoft.com/.default" as scope but didn't find any alternative to this for Sharepoint Online REST API.

I already registered an application on apps.dev.miscrosoft.com, this application is available on portal.azure.com. There I have added required permissions for Sharepoint Online.

zamazan4ik
  • 167
  • 3
  • 13

2 Answers2

2

Yes you can. To do this first you need to get a new access token using a regular refresh token you got for the graph already:

POST https://login.microsoftonline.com/{{tenantName}}/oauth2/v2.0/token

Except this time pass the following for the scope header:

https://{{tenantName}}.sharepoint.com/Sites.Read.All

Your application will need to already be consented for this scope etc...

The response will give you can access token that can be used again SPO APIs.

Chris Johnson
  • 1,230
  • 7
  • 15
  • Yes, it works. Thank you. Is it possible to request more than one scope for one token? E.g. I want to get access to Sharepoint REST API and MS Graph API. I tried to write scope header like "FirstScope SecondScope" but it failed. – zamazan4ik Mar 13 '19 at 09:02
  • @zamazan4ik id you URL encode them? i.e. offline_access%20user.read%20mail.read ? – Chris Johnson Mar 13 '19 at 17:31
  • Yes, like that. "https://graph.microsoft.com/.default%20https://mysite.sharepoint.com/.default" – zamazan4ik Mar 14 '19 at 11:01
0

It should be the same authentication with Azure AD, the scope you are looking for should be the Site scopes.

https://learn.microsoft.com/en-us/graph/permissions-reference?view=graph-rest-beta#sites-permissions

Do not have SharePoint sites to check but if permission are granted to the application you should be able to query SharePoint site using Azure Graph APIs.

https://learn.microsoft.com/en-us/graph/api/resources/sharepoint?view=graph-rest-beta

Overview

https://learn.microsoft.com/en-us/graph/sharepoint-concept-overview

Hannel
  • 1,656
  • 3
  • 10
  • 17