使用Graph API和PowerShell将敏感度标签更新到M365组引发401错误 [英] Update sensitivity label to M365 Group with Graph API and PowerShell throws 401 error

查看:19
本文介绍了使用Graph API和PowerShell将敏感度标签更新到M365组引发401错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

啊!

尝试使用Graph API和PowerShell更新M365组敏感标签信息时遇到401错误。使用Graph Explorer时,野兽工作得很好,但是使用PowerShell时,我收到了一个错误Invoke-RestMethod:the remote server return an error:(401)Underated.-message。更新组Description和DisplayName以编程方式工作,无异常。Azure应用程序注册获得应用程序级别授权的同意:Group.ReadWrite.All和Directory.ReadWrite.All,所有这些都在MS文档中提到。有什么想法吗?

代码示例:

Connect-PnPOnline -Url $tenantBaseUrl -ClientId $clientId -Tenant $tenantId -Thumbprint $thumbPrint
$body=@"
{
    "assignedLabels": [
      {
        "labelId": "$labelId"  
      }
    ]
  }
"@
$AccessToken = (Get-PnPGraphAccessToken)
$headers = @{ Authorization=("Bearer " + $AccessToken)}
$uri = "https://graph.microsoft.com/beta/groups/$groupId"
$webRequest = Invoke-RestMethod –Uri $uri -Body $body –Method Patch -Headers $headers -ContentType "application/json"
参考MS文档: https://docs.microsoft.com/en-us/graph/api/group-update?view=graph-rest-beta&tabs=http#example-2-apply-sensitivity-label-to-a-microsoft-365-group

推荐答案

似乎不支持仅应用权限。

Setting of sensitivity labels is not available with app credentials

这篇关于使用Graph API和PowerShell将敏感度标签更新到M365组引发401错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆