azure - Microsoft Graph API 获取组事件

标签 azure powershell microsoft-graph-api

我正在尝试使用 MS Graph API(我是新手)编写 Powershell 脚本,将事件从私有(private)组日历复制到公共(public)强>组日历。

到目前为止,我已经成功使用此调用获取私有(private)组:

$api = "https://graph.microsoft.com/v1.0/groups"
$groups = $null
try { $groups = Invoke-RestMethod -Headers @{Authorization = "Bearer $($token.access_token)" } -Uri $api -Method "GET" -ContentType "application/json" }
catch { Write-host -Foreground Red $_}
$calendar_group = $groups.value | ? -Property mailNickname -eq $pvt_group

但是,当我尝试向前移动并获取该组的事件时,我会因 403 错误而被退回。

我正在尝试的调用是:

$api = "https://graph.microsoft.com/v1.0/groups/$group_ID/calendar/events"
Write-Host $api -Fore Green
$events = $null
try { $events = Invoke-RestMethod -Headers @{Authorization = "Bearer $($token.access_token)" } -Uri $api -Method "GET" -ContentType "application/json" }
    catch { Write-host -Foreground Red $_}

或者:

$api = "https://graph.microsoft.com/v1.0/groups/$group_ID/events"
Write-Host $api -Fore Green
$events = $null
try { $events = Invoke-RestMethod -Headers @{Authorization = "Bearer $($token.access_token)" } -Uri $api -Method "GET" -ContentType "application/json" }
catch { Write-host -Foreground Red $_}

两者都因同一错误而失败。 注意:第一次调用时 $group_ID 变量的值是正确的。

我已在 Azure 上注册了该应用并具有以下权限:

  1. 日历.读取委托(delegate)
  2. 日历.读取.共享委托(delegate)
  3. Calendars.ReadWrite 委托(delegate)
  4. Calendars.ReadWrite.Shared 委托(delegate)
  5. Directory.AccessAsUser.All 已委派
  6. Directory.Read.All 已委派
  7. Directory.Read.All 应用程序
  8. Directory.ReadWrite.All 已委派
  9. Directory.ReadWrite.All 应用程序
  10. Group.Read.All 已委派
  11. Group.Read.All 应用程序
  12. Group.ReadWrite.All 已委派
  13. Group.ReadWrite.All 应用程序
  14. GroupMember.Read.All 已委派
  15. GroupMember.Read.All 应用程序
  16. User.Read 已委托(delegate)

有人知道我做错了什么吗? 非常感谢。

最佳答案

您使用的访问 token 是应用程序访问 token (权限在角色部分下定义)。如果使用用户访问 token ,您将在 de scp 部分下看到权限。

在 Microsoft 文档 ( here ) 中,不幸的是,应用程序访问 token 不支持调用/calendar/events。 printscreen permissions

如果您将帐户分配给群组管理员角色,您将隐式获得Group.Read.All权限。然后使用您帐户中的访问 token 调用端点,不会出现任何问题(因为您已经在应用程序注册中授予了委派所需的权限)。

关于azure - Microsoft Graph API 获取组事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68726496/

相关文章:

azure - 如何在 Azure HDInsight 的 Spark 集群中配置 HBase?

string - 在PowerShell中重命名许多文件夹

office365api - 使用 Microsoft Graph 运行宏

javascript - 是否可以在没有服务器的情况下对 Microsoft Graph 进行身份验证?

azure - 使用 Azure PowerShell 进行数据库迁移

azure - Microsoftgraph 示例无法正常工作

.net - 如何让 Powershell TabExpansion 打印所有可能的补全?

powershell - 如何在Powershell中将文本文件转换为CSV?

microsoft-graph-api - 无法从 Microsoft Graph Explorer 更新 Sharepoint 托管元数据字段

azure - 对于 Azure Active Directory 中的注册应用程序,Office 365 Exchange Online 权限不可见