【发布时间】:2019-08-09 07:47:47
【问题描述】:
我正在尝试与 Outlook 的 API 集成(更具体地说,我想列出用户的联系人,并能够对他们进行一些 CRUD)。
我在 Azure 上创建了一个 Azure 帐户、一个 Office 365 开发人员帐户和一个应用程序。
我可以使用登录端点获取访问令牌,如下所示:
https://login.microsoftonline.com/<tenant_id>/oauth2/token
我还可以使用不记名令牌通过/users 端点检索用户列表或获取用户的详细信息。 “get user”方法的结果返回如下:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [],
"displayName": "Renato Oliveira",
"givenName": "Renato",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Oliveira",
"userPrincipalName": "renato.company.com.br#EXT#@renatocompanycom.onmicrosoft.com",
"id": "<user_id>"
}
当然,这是使用/users端点传递user_id:
https://graph.microsoft.com/v1.0/users/<user_id>
但是,我无法获取此用户的联系人。当我向下面的端点发送 GET 请求时
https://graph.microsoft.com/v1.0/users/<user_id>/contacts
我收到以下错误:
{
"error": {
"code": "OrganizationFromTenantGuidNotFound",
"message": "The tenant for tenant guid '<my_active_directory_tenant_id>' does not exist.",
"innerError": {
"request-id": "<request_id>",
"date": "2019-03-18T20:43:16"
}
}
}
为什么会这样?为什么它可以与/users 一起工作,但不能与/users/{id}/contacts 一起工作,即使应用程序已激活所有权限,并且默认目录已获得管理员同意?
【问题讨论】:
-
您是否使用了同时也是电子邮件地址的用户 ID 进行测试?
-
我用的是用户的uuid