azure-active-directory - 无法更新 Azure 门户上的 B2C 本地用户个人资料照片/使用带有应用程序颁发令牌的 Graph
问题描述
我有 B2C 本地帐户,当我尝试使用带有应用程序颁发令牌的 Graph API 获取/更新他们的个人资料信息时,它起作用了。但是当我尝试获取/更新他们的个人资料照片时,我收到 404 错误。
请求:(获取)
https://graph.microsoft.com/v1.0/users/{userOid}/photo
回复:404
{
"error": {
"code": "ImageNotFound",
"message": "Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.",
"innerError": {
"date": "2021-10-26T16:12:52",
"request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb",
"client-request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb"
}
}
}
request: (PUT/POST) 并设置内容类型
https://graph.microsoft.com/v1.0/users/{userOid}/photo/$value
回复:404
{
"error": {
"code": "UnknownError",
"message": "{\r\n \"errorCode\": \"ErrorUserResolutionFailedUserDoesNotExist\",\r\n \"message\": \"Exception of type 'Microsoft.Fast.Profile.Core.Exception.ProfileNotFoundException' was thrown.\",\r\n \"target\": null,\r\n \"details\": null,\r\n \"innerError\": null,\r\n \"instanceAnnotations\": []\r\n}",
"innerError": {
"date": "2021-10-26T16:13:55",
"request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b",
"client-request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b"
}
}
}
解决方案
目前,您正在使用 Microsoft Graph REST API V1.0 来获取/更新 B2C 本地帐户的用户照片。
但是1.0版本的这些操作只支持用户的工作或学校邮箱,不支持个人邮箱
因此,您可以使用 Microsoft Graph REST API 测试版来获取/更新 B2C 本地帐户的用户照片。
使用 beta 版本获取/更新用户照片时,此操作首先尝试获取/更新 Microsoft 365 中的照片。如果失败(由于用户没有邮箱),此 API 将尝试获取/更新 Microsoft 365 中的照片Azure 活动目录
注意:要为用户更新个人资料照片,请仅使用 PUT 操作。
要获取用户的头像,请确保用户在 Azure AD 中有头像。否则,它会抛出ImageNotFound错误。
参考:
推荐阅读
- node.js - Mongo聚合忽略$match中的日期范围过滤器
- moving-average - 如何使用 vega-lite 在折线图上分层移动平均线?
- scala - Scala Akka 类型未指定值参数
- haskell - 是否可以有一个数据类型只有另一个数据类型的构造函数?
- ruby - 是否将字符串传递回 FFI 模块中必要的调用代码以防止内存泄漏?
- java - 有什么方法可以删除 JShell 中的历史记录?
- java - 如何更新方法中的值?
- excel - Excel 的 Range.Value 属性在更新后不再与 xlRangeValueMSPersistXML 参数一起使用
- google-apps-script - 用于从文件夹中的所有工作表中获取唯一值的 Google Apps 脚本
- python - 使用 OOP 运行 python 脚本时出错