Microsoft Graph API - 创建应用程序(测试版)

bor*_*a89 3 azure-active-directory microsoft-graph-api

我们正在尝试application resource type按照此处所述进行创建:https : //github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/resources/application.md

请求:

POST https://graph.microsoft.com/beta/applications

{
  "displayName": "MyCoolApp",
  "passwordCredentials": [{
    "customKeyIdentifier":"ObJix/HDVU+3+hH5RmA+dw==",
    "endDateTime":"2018-10-19T17:59:59.6521653Z",
    "keyId":"ed087fba-0068-431f-98d7-e6b74dedd931",
    "startDateTime":"2016-10-19T17:59:59.6521653Z",
    "value":"somepass"
  }]
}
Run Code Online (Sandbox Code Playgroud)

结果是:

{
  "error": {
    "code": "Request_BadRequest",
    "message": "The property 'value' does not exist on type 'Microsoft.DirectoryServices.PasswordCredential'. Make sure to only use property names that are defined by the type.",
    "innerError": {
      "request-id": "038aa3bd-2b99-4329-a2ae-bc11d2f64609",
      "date": "2018-02-04T14:23:57"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

怎么value不存在?这是passwordCredentials资源的 JSON 表示

{
  "customKeyIdentifier": "binary",
  "endDate": "String (timestamp)",
  "keyId": "guid",
  "startDate": "String (timestamp)",
  "value": "string"
}
Run Code Online (Sandbox Code Playgroud)

在这里:https : //github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/resources/passwordcredential.md

但是,我们可以创建一个指定了空 PasswordCredential 的应用程序 - 是的应用程序已创建,我们在应用程序列表(https://apps.dev.microsoft.com/#/appList)上看到它,但我们需要知道它的凭据无论如何。

有什么方法可以使用提供的凭据以编程方式创建 APP?

bor*_*a89 6

好的,伙计们,我已经想通了。文档显然已经过时,所以passwordCredentials现在正确的架构:

[{
  "customKeyIdentifier": "binary",
  "endDateTime": "String (timestamp)",
  "keyId": "guid",
  "startDateTime": "String (timestamp)",
  "secretText": "string"
}...]
Run Code Online (Sandbox Code Playgroud)

secretText是您应用程序密码的新属性名称,不再使用"value"

我最终只使用了 2 个道具:

{
  "endDateTime": "2020-10-19T17:59:59.53Z",
  "secretText": "should be 16-64 characters long"
}
Run Code Online (Sandbox Code Playgroud)

我现在要做一个拉取请求来更改他们的文档

顺便说一句,这是一个资源的完整模式,它帮助我找到了答案: https://graph.microsoft.com/beta/$metadata#applications/$entity