How to read IRM protected excel file using graph api from backend code
We have a requirement to programmatically read IRM Protected excel file with Graph API using a backend process which is a AWS Lambda function.
Below setup works fine to read an excel file which doesnt have any protection.
- Azure app registration has been created to authorize requests to sharepoint, it has all permissions required w.r.t Graph api.
- AWS Lambda uses the client credentials of Azure app registration to connect to excel in sharepoint using below graph api endpoint
- Azure app has been added to the sharepoint site
- Able to read excel files without IRM protection successfully from AWS Lambda.
- However, there is an excel file with IRM Protection which gives error as shown below when tried to run the AWS Lambda function.
{
"response": {
"error": {
"code": "OpenWorkbookAccessDenied",
"message": "You do not have permissions to open this file.",
"innerError": {
"code": "forbiddenUncategorized",
"message": "The request is not allowed.",
"innerError": {
"code": "OpenWorkbookAccessDenied",
"message": "You do not have permissions to open this file."
},
"date": "2024-12-20T06:39:24",
"request-id": "1df612e0-234f-4cf6-9f17-c5664ec97b60",
"client-request-id": "1df612e0-234f-4cf6-9f17-c5664ec97b60"
}
}
}
}
Note:
"Access content Programmatically" option has been enabled in the excel, as described in below article https://support.microsoft.com/en-us/office/restrict-access-to-documents-with-information-rights-management-in-word-94aa8ab1-465e-42d7-a323-d61f911b2d0f
I understand that the permissions can be granted to users within the IRM Protected excel, however what type of account can be used to read the file programmatically.
Please advise.
Regards,
Sharath Molagavalli