gpt4 book ai didi

azure - Graph API - 无法获取除我自己之外的任何其他用户的日历事件

转载 作者:行者123 更新时间:2023-12-03 06:18:04 27 4
gpt4 key购买 nike

我不明白这个问题。我的用户是测试 Azure 目录的管理员,并且我有自动设置的虚拟用户。我可以使用我的电子邮件为自己获取日历事件:

https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3158505c45595450555c585f714609455d451f5e5f5c5852435e425e57451f525e5c" rel="noreferrer noopener nofollow">[email protected]</a>/calendar/events

但每当我尝试从任何其他虚拟用户检索日历事件(只需切换 GraphAPI 请求 URL 中的电子邮件地址)时,我都会在 Graph Explorer 中收到以下错误:

"code": "ErrorItemNotFound",
"message": "The specified object was not found in the store.",

我尝试检索事件的虚拟用户的日历中有多个事件,因此空日历绝对不是问题。

我已在 Azure AD/应用程序注册/API 权限中设置了权限:

enter image description here

我不知道我缺少什么细节/设置/权限。

最佳答案

我尝试在我的环境中重现相同的结果并得到以下结果:

我注册了一个 Azure AD 应用程序并添加了相同的 API 权限,如下所示:

enter image description here

当我在 Graph Explorer 中运行相同的查询时,我可以使用我的电子邮件为自己获取日历事件,如下所示:

GET https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b56425a5858544e554f7b434343434343155455565258495448545d4f15585456" rel="noreferrer noopener nofollow">[email protected]</a>/calendar/events

回应:

enter image description here

但是当我尝试检索其他用户的日历事件时,我收到相同的错误,如下所示:

GET https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa5bea2afb8bfb9afb88ab2b2b2b2b2b2e4a5a4a7a3a9b8a5b9a5acbee4a9a5a7" rel="noreferrer noopener nofollow">[email protected]</a>/calendar/events

回应:

enter image description here

出现错误的原因是 Graph Explorer 使用委派权限,但检索其他用户日历事件需要应用程序权限。

As you already assigned Application permissions in your application, just generate an access token using client credentials flow and use it to run Graph queries.

就我而言,我使用 Postman 生成访问 token 客户端凭据流程如下:

POST https://login.microsoftonline.com/<tenantID>/oauth2/v2.0/token
grant_type:client_credentials
client_id:<appID>
client_secret:<secret>
scope:https://graph.microsoft.com/.default

回应:

enter image description here

当我使用此 token 运行下面的图形查询时,我成功获取了其他用户的日历事件,如下所示:

GET https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0669726e637473756374467e7e7e7e7e7e2869686b6f657469756960722865696b" rel="noreferrer noopener nofollow">[email protected]</a>/calendar/events

回应:

enter image description here

关于azure - Graph API - 无法获取除我自己之外的任何其他用户的日历事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76063505/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com