在Microsoft Graph API中获取个人资料图片一无所获 [英] Getting profile picture in Microsoft Graph API finds nothing

查看:47
本文介绍了在Microsoft Graph API中获取个人资料图片一无所获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

I'm trying to get the profile picture of users (and, ideally, the fallback initials with different-colored backgrounds in case they don't have one) using the Microsoft Graph API, but I can't get it to respond with anything but 404 status and the following body (annoyingly also after a delay of 5-20 seconds):

{
    "error": {
        "code": "ResourceNotFound",
        "message": "Resource could not be discovered.",
        "innerError": {
            "request-id": "1e7f0ca4-2cd4-4602-a903-b0bde1ec8ea0",
            "date": "2018-06-11T14:04:10"
        }
    }
}

我什至尝试使用在线图形浏览器,但结果相同.我已将个人资料照片上传到自己的帐户,但仍然得到相同的结果.

I've even tried with the online Graph Explorer, but with the same results. I've uploaded a profile picture to my own account, but I still get the same results.

可能是什么原因?还有其他方法可以获取Azure AD用户的个人资料图片吗?

What could be the cause? Are there other ways to get at the profile picture of an Azure AD user?

推荐答案

Microsoft Graph v1.0从Exchange Online(而不是Azure Active Directory)检索用户的 profilePhoto .因此,没有在Exchange Online中配置邮箱的用户将没有可用的 profilePhoto .

Microsoft Graph v1.0 retrieves the user's profilePhoto from Exchange Online, not Azure Active Directory. As such, users that don't have a mailbox provisioned in Exchange Online will not have a profilePhoto available.

文档:

从Exchange Online访问的用户,组或Outlook联系人的个人资料照片.它是二进制数据,未在base-64中编码.

A profile photo of a user, group or an Outlook contact accessed from Exchange Online. It's binary data not encoded in base-64.

/beta 端点中, profilePhoto 资源已扩展为包括Exchange和AAD.从测试版文档:

In the /beta endpoint, the profilePhoto resource was expanded to include both Exchange and AAD. From the Beta documentation:

从Exchange Online或Azure Active Directory(AAD)访问的用户,组或Outlook联系人的个人资料照片.它是二进制数据,未在base-64中编码.

A profile photo of a user, group or an Outlook contact accessed from Exchange Online or Azure Active Directory (AAD). It's binary data not encoded in base-64.

何时在/v1.0 端点上发布此功能尚无预计时间,并且在大多数情况下,我警告不要使用/beta 生产中的功能.但是,我看到一些开发人员使用/beta 后备选项来获取 profilePhoto :如果/v1.0 端点无法返回照片,随后调用/beta 来检查是否有可用的AAD图像.这是Beta端点的一种相对安全的用法,因为您的应用程序并未完全依赖Beta API.

There isn't an ETA on when this functionality will be released on the /v1.0 endpoint and, in most cases, I would caution against using /beta functionality in a production. I have however seen several developers use /beta fallback option for fetching a profilePhoto: If the /v1.0 endpoint fails to return a photo, a subsequent call is made to /beta to check if there is an AAD image available. This is a relatively safe use of the beta endpoint as your app isn't pulling a hard dependency on a beta API.

这篇关于在Microsoft Graph API中获取个人资料图片一无所获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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