Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Microsoft graph api Microsoft Graph API-更新密码_Microsoft Graph Api - Fatal编程技术网

Microsoft graph api Microsoft Graph API-更新密码

Microsoft graph api Microsoft Graph API-更新密码,microsoft-graph-api,Microsoft Graph Api,我正在使用MicrosoftGraphAPI示例项目。我可以很好地登录 我正在尝试使用以下代码更新登录用户的密码: 公共异步任务更新密码(GraphServiceClient graphClient,字符串newPassword) { User me=wait graphClient.me.Request().UpdateAsync(新用户 { PasswordProfile=新的PasswordProfile { Password=newPassword, ForceChangePasswor

我正在使用MicrosoftGraphAPI示例项目。我可以很好地登录

我正在尝试使用以下代码更新登录用户的密码:

公共异步任务更新密码(GraphServiceClient graphClient,字符串newPassword)
{
User me=wait graphClient.me.Request().UpdateAsync(新用户
{
PasswordProfile=新的PasswordProfile
{
Password=newPassword,
ForceChangePasswordNextSignIn=false
},
});
返回true;
}
当我执行代码时,我得到以下错误:

{
现状:500
信息:“未提供用于验证同意的报价。”
内部错误:“空的报价数组。”
}
知道我可能做错了什么吗

我通过
App注册门户访问了所有与“用户”相关的内容https://apps.dev.microsoft.com


谢谢大家!

有一个烘焙的
ChangePassword()
函数,您希望用于:

wait graphClient.Me.ChangePassword(“当前pwd,新pwd”).Request().PostAsync();

有一个烘焙的
ChangePassword()
函数,您可以使用该函数:

wait graphClient.Me.ChangePassword(“当前pwd,新pwd”).Request().PostAsync();

您最初发布的代码实际上是密码重置代码-管理员重置/更改其他用户的密码。请使用Marc的建议,该建议专为登录用户更改自己的密码而设计(通过提供旧密码和新密码)。目前,这需要授予app Directory.AccessAsUser.All权限。您最初发布的代码实际上是密码重置代码-管理员重置/更改其他用户的密码。请使用Marc的建议,该建议专为登录用户更改自己的密码而设计(通过提供旧密码和新密码)。目前,这需要授予app Directory.AccessAsUser.All权限。