[英]Azure AD B2C updating users sign in names results in error
當我嘗試更新SignInNames
列表時,我收到錯誤: Resource <EMAIL ADDRESS> does not exist or one of its queried reference-property objects are not present
。
var currentUser = await GetUserByUserNameAsync(userId); // this gets the user
var signinNames = currentUser.SignInNames.ToList();
signinNames.Add(new SignInName
{
Type = "emailAddress",
Value = newEmailaddress
});
var data = new B2CChangeEmailAddressData()
{
SignInNames = signinNames
};
var response = await _graphApi.SendAsync(new HttpMethod("PATCH"), $"users/{userId}", null, data);
然后它返回錯誤。 我使用類似的代碼來更新密碼,這很好。 我忽略了什么嗎?
所以,我做的是:
第一種是可能的,但第二種不是。 我不得不使用ObjectId
更新用戶。 所以代碼應該是:
var currentUser = await GetUserByUserNameAsync(userId);
var path = $"users/{currentUser.ObjectId}";
var signinNames = new List<SignInName>();
signinNames.Add(new SignInName
{
Type = "emailAddress",
Value = newEmailaddress
});
var data = new B2CChangeEmailAddressData()
{
SignInNames = signinNames
};
var response = await _graphApi.SendAsync(new HttpMethod("PATCH"), path, null, data);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.