Microsoft graph api 如何更新用户';使用Graph REST API的Azure AD中的hireDate属性?

Microsoft graph api 如何更新用户';使用Graph REST API的Azure AD中的hireDate属性?,microsoft-graph-api,Microsoft Graph Api,我搜索了类似的问题,但没有找到我想要的答案 我的目标是用hireDate更新AAD中的所有用户 起初,我尝试使用客户端凭据流来实现这一点 POST https://login.microsoftonline.com/espiradev.onmicrosoft.com/oauth2/token Content-Type:application/x-www-form-urlencoded grant_type:client_credentials client_id:{{client_id}} c

我搜索了类似的问题,但没有找到我想要的答案

我的目标是用hireDate更新AAD中的所有用户

起初,我尝试使用客户端凭据流来实现这一点

POST https://login.microsoftonline.com/espiradev.onmicrosoft.com/oauth2/token
Content-Type:application/x-www-form-urlencoded

grant_type:client_credentials
client_id:{{client_id}}
client_secret:{{client_secret}}
resource:https://graph.microsoft.com
在我获得访问代码后,我打电话:

PATCH https://graph.microsoft.com/v1.0/users/[user1]
Authorization:bearer {{access_token}}
Content-Type:application/json
{
 "hireDate": "2019-05-01T00:00:00Z"
}
答复:

"error": {
  "code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
  "message": "Attempted to perform an unauthorized operation.",
  "innerError": {}
}
"error": {
   "code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
   "message": "Attempted to perform an unauthorized operation.",
   "innerError": {}
}
第二次尝试是使用密码流(客户端和用户凭据)。我使用了我的全局管理员[user1]凭据并调用了相同的HTTP请求。响应是HTTP 204(一切正常)

不幸的是,当我尝试更新其他[user2]时,结果如下:

PATCH https://graph.microsoft.com/v1.0/users/[user2]
Authorization:bearer {{access_token}}
Content-Type:application/json
{
  "hireDate": "2019-05-01T00:00:00Z"
}
答复:

"error": {
  "code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
  "message": "Attempted to perform an unauthorized operation.",
  "innerError": {}
}
"error": {
   "code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
   "message": "Attempted to perform an unauthorized operation.",
   "innerError": {}
}
如果我正在使用[user2]凭据获取访问令牌,那么我可以更新[user2]hireDate,但不能更新[user1]

应用程序权限:

更新: 解码的访问令牌具有以下权限:

"scp": "Directory.AccessAsUser.All Directory.ReadWrite.All User.ManageIdentities.All User.ReadWrite User.ReadWrite.All"
更新[2]: [user1]和[user2]都已分配Office 365 E1许可证(包括SharePoint Online(计划1))


我做错什么了吗?如果任何人都有共享解决方案,我们将不胜感激。

除了office许可证之外,全局管理员用户还应该在令牌中拥有Sites.ReadWrite.All作用域权限,以便为其他用户更新“hireDate”属性。

您是否检查了访问令牌是否具有所有这些作用域?你能分享解码的令牌内容吗?是的,我检查了解码的访问令牌,所有提到的权限都在那里。将此信息添加到post。您的租户是否拥有SPO许可证?[user1]和[user2]都已分配Office 365 E1许可证(包括SharePoint Online(计划1))。这就是你要的还是我遗漏了什么?就是这样。谢谢,我已经在看这个了,会尽快让你知道的。谢谢,这正是我所缺少的。微软没有回应如何解决这个问题(到处都有报道)。这就是有效的修复方法!惊人的反应。非常感谢。