Question

I registered an app in Azure Active Directory and granted several privileges:

enter image description here

Then I got myself a bearer token by calling:

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

with the scope:

 https://{tenantName}.sharepoint.com/.default

When I use that token to make an API call like:

https://infoinnobake.sharepoint.com/_api/search/query?querytext='contentclass:STS_Site contentclass:SP.Webb'&selectproperties='Title,Path'&rowlimit=500`

I only reveice 401 Unsupported app only token.

can some explain why?

Is it possible to access the SharePoint online API with an registered App on Azure AD?

Was it helpful?

Solution

Many thanks to @GaneshSanap for providing me a solution. You need to create a self signed cert and upload it to the registered app in AAD. Follow this guide to do so:

Granting access via Azure AD App-Only.

OTHER TIPS

In Order to call SharePoint Online API using Azure AD Registered App, you need to Set up an Azure AD app for app-only access and grant the permissions to it.

Please read below article for more clarification:

Granting access via Azure AD App-Only.

Additional References:

  1. Connect to API secured with Azure Active Directory.
  2. Connect to Azure AD-secured APIs in SharePoint Framework solutions.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top