gpt4 book ai didi

azure - 在 Graph 中检索照片时从 Microsoft 获取 "AuthenticationError"

转载 作者:行者123 更新时间:2023-12-02 23:42:51 24 4
gpt4 key购买 nike

我正在使用仅限应用程序的权限查询 Microsoft Graph,因为我正在对目录中的所有用户执行操作。当我查询 onPremisesSamAccountName 时使用我的 token ,我没有任何问题。但是,当我尝试检索用户的照片(使用相同的 token )时,我得到以下信息:

StatusCode: 400 Bad Request
Error Code: AuthenticationError
Error Message: Error authenticating with resource

我在租户中分配了以下仅限应用程序的权限:

  • User.Read.All(申请,管理员同意)
  • Directory.Read.All(申请,管理员同意)

详细信息:

  • URI:https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="204d595553455260444f4d41494e0e434f4d" rel="noreferrer noopener nofollow">[email protected]</a>/photo/$value
  • 范围:https://graph.microsoft.com/.default
  • 内容类型:application/json
  • 授权 header :"bearer _my token string_"

这是我的请求(在 ColdFusion 中):

<cfhttp method="get" charset="utf-8" url="https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1ccd8d4d2c4d3e1c5ceccc0c8cf8fc2cecc" rel="noreferrer noopener nofollow">[email protected]</a>/photo/$value" result="resp">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="header" name="Authorization" value="bearer Oxfd989309sdf...">
</cfhttp>

我得到的回复就是我上面显示的内容。当我通过http://jwt.calebb.net/运行我的 token 时,我没有看到任何范围设置。

我尝试通过 Graph Explorer 运行它。我以我自己的身份登录,然后运行 ​​URI https://graph.microsoft.com/v1.0/me/photo ,我收到的回复是:

{
"error": {
"code": "ErrorItemNotFound",
"message": "The photo wasn't found.",
"innerError": {
"request-id": "ebae50f8-b636-4e61-9d92-eab4b48ef0c2",
"date": "2019-08-08T19:13:50"
}
}
}

我希望如此,因为我没有照片。

当我使用 URI https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="016c7874726473416c78656e6c60686f2f626e6c" rel="noreferrer noopener nofollow">[email protected]</a>/photo/$value 时,我得到以下响应:

{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "40246947-57d6-4016-a55a-c1ad5f0736e4",
"date": "2019-08-08T19:16:37"
}
}
}

我按照 the documentation 设计了我的请求其中显示了示例 GET

GET /users/{id | userPrincipalName}/photo/$value

我是否错过了一个步骤,或者遗漏了一个范围?

最佳答案

When I run my token through http://jwt.calebb.net/, I don't see anyscopes set.

当您使用客户端凭证流程获取 token 时,您将获得角色下的权限。

enter image description here

I tried running this through Graph Explorer. I signed in as myself,then I ran the URI https://graph.microsoft.com/v1.0/me/photo, theresponse I received was:404

就像 @Marc LaFleur 在评论中所说,确保用户配置了 Exchange Online 邮箱,并上传了个人资料图片。

关于azure - 在 Graph 中检索照片时从 Microsoft 获取 "AuthenticationError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57419444/

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