我正在尝试使用带有客户端 ID 的图形休息 API 来重置用户密码。我已经使用 UserAuthenticationMethod.ReadWrite.All 创建了应用程序,并将该应用程序添加到了用户管理员中。当使用 Postman 调用请求时,我收到以下错误。是什么原因造成这个问题。我也在标头中为客户端传递 OAuth 令牌。
我正在使用这个终点。
https://graph.microsoft.com/v1.0/users('[email protected]')/authentication/methods/{clientid}/resetPassword
我已向该应用程序授予以下权限。
最初,我注册了一个 Entra ID 应用程序并授予了 API 权限,如下所示:
将上述应用程序添加到用户管理员目录角色,如下所示:
现在,我使用客户端凭证流通过 Postman 生成 OAuth 令牌,参数如下:
POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token
grant_type:client_credentials
client_id:appID
client_secret:secret
scope: https://graph.microsoft.com/.default
回复:
当我使用此令牌通过调用下面的 API 来重置用户密码时,我也遇到了同样的错误:
POST https://graph.microsoft.com/v1.0/users/userID/authentication/methods/methodId/resetPassword
{
"newPassword": "xxxxxxx"
}
回复:
或者,您可以使用重置用户密码操作时发生错误不支持
Application
在此MS Doc中提到的权限。
Update user API 调用通过更新 passwordProfile
PATCH https://graph.microsoft.com/v1.0/users/{id}
{
"passwordProfile": {
"forceChangePasswordNextSignIn": false,
"password": "xxxxxxxx"
}
}
回复: