Calling Sharepoint Online API using Azure AD Registered App
-
07-02-2021 - |
Question
I registered an app in Azure Active Directory and granted several privileges:
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?
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:
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: