如何使用 azure AD 图获取客户端密码到期日期 API

How to get client secret expiry date using the azure AD graph API

我正在尝试获取我们的 AAD 应用程序的客户端机密的到期日期。但是,当我使用以下图形请求时,passwordCredential 和 keyCredential 字段为空。

https://graph.windows.net/myorganization/directoryObjects/{ServicePrincipalObjectId}/?api-version=1.6

有没有办法获取这些数据?如果我下载它,我会在清单中看到它,只是不在 Odata 对象中

感谢您的帮助!

使用下面的 AAD 图 API:

https://graph.windows.net/{org_domain}/applications/{obj_id}/passwordCredentials

响应将显示您的特定 AAD 应用程序使用的密钥列表。

您可以从 endDate 字段中得出密钥的到期日期。

{
  "odata.metadata": "https://graph.windows.net/{org_domain}/$metadata#Collection(Microsoft.DirectoryServices.PasswordCredential)",
  "value": [
    {
      "customKeyIdentifier": null,
      "endDate": "2018-05-07T09:12:13.2177408Z",
      "keyId": "{your_key_id}",
      "startDate": "2016-05-07T09:12:13.2177408Z",
      "value": null
    }
  ]
}

作为使用 Graph API 的替代方法,您还可以考虑将 Get-AzAdApplication cmdlet 与 Get-AzAdAppCredential 一起使用,它们是 Az PowerShell

的一部分

https://docs.microsoft.com/en-us/powershell/module/az.resources/get-azadappcredential?view=azps-5.5.0