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

时间:2018-02-04 15:13:59

标签: azure-active-directory microsoft-graph

我们正在尝试按照此处所述创建application resource typehttps://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"
  }]
}

结果是:

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

为什么value不存在? 这是passwordCredentials资源

的JSON表示
{
  "customKeyIdentifier": "binary",
  "endDate": "String (timestamp)",
  "keyId": "guid",
  "startDate": "String (timestamp)",
  "value": "string"
}

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

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

有没有办法以编程方式创建一个提供凭据的APP?

1 个答案:

答案 0 :(得分:4)

好吧,伙计们,我已经明白了。文档显然已经过时,因此现在passwordCredentials的正确架构:

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

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

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

{
  "endDateTime": "2020-10-19T17:59:59.53Z",
  "secretText": "should be 16-64 characters long"
}

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

BTW,这是一个资源的完整模式,帮助我找到它:https://graph.microsoft.com/beta/$metadata#applications/$entity