I have an Provider Hosted SharePoint app registered using appreg.aspx. I want to get details of that app like app name, client secret start and end date using Azure Function, so that I can send alert before the app client secret expires. I have already increased the date to 3 years using the PowerShell script.
I went through the question, Alert on Client Secret Key Expiry. But it seems the solution is older. I have used PowerShell script to get app details but I want to use Azure Function as I already have few other functions so maintaining them will be easier.
Is there a way to get app details using Graph REST API?
Thank you!
Use https://graph.microsoft.com/beta/servicePrincipals?$filter=appId eq '{app id of your app registered in SharePoint}'
to get the the app details.
You can find client secret endDateTime in the response (the app name is also included):
"passwordCredentials": [
{
"customKeyIdentifier": null,
"endDateTime": "2021-01-16T01:56:20.4750596Z",
"keyId": "653b5550-23c0-4bff-9fab-f34e91d23dc6",
"startDateTime": "2020-01-16T01:56:20.4750596Z",
"secretText": null,
"hint": null,
"displayName": null
}
See reference here. And you can have a qucik test in Microsoft Graph Explorer.