You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Microsoft Graph API在Azure B2C创建用户返回400错误问题咨询

解决方案

报错的核心原因是identities字段要求传入数组格式,你之前直接传入单个ObjectIdentity实例不符合接口要求,即使只配置一个登录身份,也要用数组包裹后再传入,修改对应代码即可:

// 创建ObjectIdentity的原有逻辑不变
$identities = new ObjectIdentity();
$identities->setSignInType("emailAddress");
// 注意issuer需填写你的B2C租户域名,格式为xxx.onmicrosoft.com,不要填写租户ID
$identities->setIssuer("你的B2C租户域名");
$identities->setIssuerAssignedId("email@dot.com");

// 核心修改:将身份对象放入数组后再调用setIdentities
$newUser->setIdentities([$identities]);

其他注意事项

  • 配置的密码需要符合Azure B2C的密码复杂度要求,否则也会返回400错误
  • 确保你注册的应用已经授予User.ReadWrite.All应用权限,且完成了管理员同意操作

内容的提问来源于stack exchange,提问作者Lorenzo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 04:54:07