我正在尝试与 Outlook 的 API 集成(更具体地说,我想列出用户的联系人,并能够对他们执行一些 CRUD)。
我在 Azure 上创建了一个 Azure 帐户、一个 Office 365 开发人员帐户和一个应用程序。
我可以使用登录端点获取访问令牌,如下所示:
https://login.microsoftonline.com/<tenant_id>/oauth2/token
Run Code Online (Sandbox Code Playgroud)
我也可以/users使用不记名令牌通过端点检索用户列表或获取用户的详细信息。“获取用户”方法的结果返回如下内容:
{
"@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>"
}
Run Code Online (Sandbox Code Playgroud)
当然,这是使用在其上/users传递的端点user_id:
https://graph.microsoft.com/v1.0/users/<user_id>
Run Code Online (Sandbox Code Playgroud)
但是,我无法获取该用户的联系人。当我向下面的端点发送 GET 请求时
https://graph.microsoft.com/v1.0/users/<user_id>/contacts
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
{
"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"
}
} …Run Code Online (Sandbox Code Playgroud)