如何通过Microsoft Graph为Azure B2C租户设置品牌Logo及背景图?
用Microsoft Graph设置Azure B2C租户的Logo/背景图
和设置backgroundColor的JSON PATCH请求不同,Logo和背景图需要通过PUT请求上传二进制文件来完成,具体操作如下:
设置组织Logo
使用PUT接口上传Logo的二进制数据,接口地址:PUT https://graph.microsoft.com/v1.0/organization/{organizationId}/branding/logo
关键要求:
- 请求头必须指定
Content-Type为图片对应的MIME类型,比如image/png或image/jpeg - 图片需满足:仅支持PNG/JPG格式,尺寸不超过240x240像素,文件大小≤100KB
示例curl命令:
curl --request PUT 'https://graph.microsoft.com/v1.0/organization/{organizationId}/branding/logo' \ --header 'Authorization: Bearer {你的访问令牌}' \ --header 'Content-Type: image/png' \ --data-binary '@本地Logo文件路径.png'
设置登录页背景图
背景图的上传逻辑和Logo一致,接口地址为:PUT https://graph.microsoft.com/v1.0/organization/{organizationId}/branding/signInPageBackgroundImage
关键要求:
- 请求头
Content-Type匹配图片格式 - 背景图推荐尺寸1920x1080像素,支持PNG/JPG,文件大小≤1MB
示例curl命令:
curl --request PUT 'https://graph.microsoft.com/v1.0/organization/{organizationId}/branding/signInPageBackgroundImage' \ --header 'Authorization: Bearer {你的访问令牌}' \ --header 'Content-Type: image/jpeg' \ --data-binary '@本地背景图文件路径.jpg'
如果需要验证已上传的图片,直接用GET请求访问对应接口即可,比如:GET https://graph.microsoft.com/v1.0/organization/{organizationId}/branding/logo
内容的提问来源于stack exchange,提问作者Kathiea
相关产品推荐
相关产品推荐

