Unexpected behavior when getting worksheets of a workbook
I am trying to list worksheets of a workbook via /me/drive/items/{id}/workbook/worksheets endpoint, but something weird is happening. I have two Microsoft Entra applications (for simplicity, I will refer to them as A and B). First, I am trying to receive an access token via OAuth2.0 in Postman with the following scopes: files.read.all, files.readwrite, openid, profile, user.read to the A application. Then I use the acquired token in the Authorization header. When sending a request to /me/drive/items/{id}/workbook/worksheets the following error is received:
{
"error": {
"code": "FileOpenUserUnauthorized",
"message": "You do not have permissions to open this file in the browser.",
"innerError": {
"code": "unauthorizedUncategorized",
"message": "Required authentication information for the resource is either missing or invalid.",
"innerError": {
"code": "FileOpenUserUnauthorized",
"message": "You do not have permissions to open this file in the browser."
},
"date": "2024-08-13T11:43:20",
"request-id": "2af4c4a8-0ba7-49a5-bc71-218dffcbac6a",
"client-request-id": "2af4c4a8-0ba7-49a5-bc71-218dffcbac6a"
}
}
}
Then, I am trying to receive an access token via OAuth2.0 to the B application with the same scopes as before and send the same request. However, this time, no error is received and I get a successful response.
But then, I am trying to use the A access token once again and everything works as expected! I didn't receive a new token, just switched between the two. I am very much troubled by this behavior and don't understand why the A access token doesn't work from the get go or what I should change in the A application to make it work.
I can provide you both access tokens and links to the workbook if needed.
Thank you.