I am receiving the error (401) Unauthorized: "General exception while processing" while trying to call "https://{tenant-name}.sharepoint.com/_api/v2.0/sites" (with my tenant name substituted in). I found this here: https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph
Request details:
GET https://{tenant-name}.sharepoint.com/_api/v2.0/sites
Authorization: "Bearer {access token}"
I have followed the process for registering an setting up an app in Azure AD: https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
I believe the root of the issue may be at the stage of acquiring my access token. I have received different errors at this same stage, when acquiring a token with different parameters.
Here are the details of my initial token request (the token is then used in the above request):
POST https://login.microsoftonline.com/{tenant-ID}/oauth2/v2.0/token
Body: client_id=[client_id]&client_secret=[client_secret]&grant_type=client_credentials&scope=[scope]
I have tried the following two scopes in the request body:
api://[app ID]/.default
https://[tenant-name].sharepoint.com/.default
Additionally, if I use the user authorization flow to receive a token, providing scope="offline_access Sites.Read.All"
My application receives the authorization code, which it then exchanges for an access token. When I try to call the same "/sites" request mentioned above (using the access token), I receive the error "(401) Unauthorized: One of the provided arguments is not acceptable."