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?

有帮助吗?

解决方案

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.

其他提示

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.
许可以下: CC-BY-SA归因
scroll top