application: addPassword

命名空间:microsoft.graph

向应用程序添加强 密码

权限

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) Application.ReadWrite.All
委派(个人 Microsoft 帐户) Application.ReadWrite.All
应用程序 Application.ReadWrite.OwnedBy、Application.ReadWrite.All、Directory.Read.All

HTTP 请求

POST /applications/{id}/addPassword

请求标头

名称 说明
Authorization Bearer {token}。必需。
Content-Type application/json. Required.

请求正文

在请求正文中,提供具有以下 passwordCredential 属性的可选对象。

属性 类型 说明
displayName String 密码的友好名称。 可选。
endDateTime DateTimeOffset 密码过期的日期和时间使用 ISO 8601 格式表示,并且始终处于 UTC 时间。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。 可选。 默认值为"startDateTime + 2 年"。
startDateTime DateTimeOffset 密码生效的日期和时间。 时间戳类型表示采用 ISO 8601 格式的日期和时间信息,始终采用 UTC 时区。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。 可选。 默认值为"now"。

响应

如果成功,此方法在响应 200 OK 正文中返回 响应代码和新 passwordCredential 对象。 响应 对象中的 secretText 属性包含由 Azure Active Directory生成的强密码,长度为 16-64 个字符。 将来无法检索此密码。

示例

以下示例演示如何调用此 API。

请求

下面展示了示例请求。 请求中 指定的 id 是应用程序的 id 属性的值,而不是 appId 属性的值

POST https://graph.microsoft.com/v1.0/applications/{id}/addPassword
Content-type: application/json

{
  "passwordCredential": {
    "displayName": "Password friendly name"
  }
}

响应

下面展示了示例响应。

HTTP/1.1 200 OK
Content-type: application/json

{
    "customKeyIdentifier": null,
    "endDateTime": "2021-09-09T19:50:29.3086381Z",
    "keyId": "f0b0b335-1d71-4883-8f98-567911bfdca6",
    "startDateTime": "2019-09-09T19:50:29.3086381Z",
    "secretText": "[6gyXA5S20@MN+WRXAJ]I-TO7g1:h2P8",
    "hint": "[6g",
    "displayName": "Password friendly name"
}