Getting list of sharepoint pages in a collection returns 403

Copper Contributor

I have these permissions on a service account:

JLee59_0-1727319963196.png

1. With this service account's clientId and clientSecret, I call GET https://login.microsoftonline.com/<tenantId>/oauth2/v2.0/token to get an access_token.

2. I use this access_token to call POST https://<domain>.sharepoint.com/sites/<siteCollection>/_api/web  but get a 401.

{
"error_description": "Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."
}

So I have two questions:

1. Do I not have the right permissions? The Sites.Selected should include the <sitecollection>.

2. What permissions do I need to get a 200?

0 Replies