使用 Graph REST API 获取 SharePoint 应用详细信息

Get SharePoint App details using Graph REST API

我使用 appreg.aspx 注册了一个提供商托管的 SharePoint 应用程序。我想使用 Azure Function 获取该应用程序的详细信息,例如应用程序名称、客户端密码开始和结束日期,以便我可以在应用程序客户端密码过期之前发送警报。我已经使用 PowerShell 脚本将日期增加到 3 年。

我回答了这个问题,Alert on Client Secret Key Expiry。但似乎解决方案较旧。我已经使用 PowerShell 脚本获取应用程序详细信息,但我想使用 Azure Function,因为我已经有一些其他功能,因此维护它们会更容易。

有没有办法使用 Graph REST 获取应用详细信息API?

谢谢!

使用https://graph.microsoft.com/beta/servicePrincipals?$filter=appId eq '{app id of your app registered in SharePoint}'获取应用详情。

您可以在响应中找到客户端密码 endDateTime(也包括应用程序名称):

        "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
            }

参见参考资料 here. And you can have a qucik test in Microsoft Graph Explorer