使用Azure AD Graph REST API(代为)重置用户密码

问题描述 投票:0回答:1

我正在尝试使用带有客户端 ID 的图形休息 API 来重置用户密码。我已经使用 UserAuthenticationMethod.ReadWrite.All 创建了应用程序,并将该应用程序添加到了用户管理员中。当使用 Postman 调用请求时,我收到以下错误。是什么原因造成这个问题。我也在标头中为客户端传递 OAuth 令牌。

我正在使用这个终点。

https://graph.microsoft.com/v1.0/users('[email protected]')/authentication/methods/{clientid}/resetPassword

我已向该应用程序授予以下权限。

microsoft-graph-api postman azure-ad-graph-api
1个回答
0
投票

最初,我注册了一个 Entra ID 应用程序并授予了 API 权限,如下所示:

enter image description here

将上述应用程序添加到用户管理员目录角色,如下所示:

enter image description here

现在,我使用客户端凭证流通过 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

回复:

enter image description here

当我使用此令牌通过调用下面的 API 来重置用户密码时,我也遇到了同样的错误

POST https://graph.microsoft.com/v1.0/users/userID/authentication/methods/methodId/resetPassword
{
    "newPassword": "xxxxxxx"
}

回复:

enter image description here

重置用户密码操作时发生错误不支持Application

在此
MS Doc中提到的权限。

或者,您可以使用

Update user API 调用通过更新 passwordProfile

 属性来重置用户密码,如下所示:

PATCH https://graph.microsoft.com/v1.0/users/{id} { "passwordProfile": { "forceChangePasswordNextSignIn": false, "password": "xxxxxxxx" } }

回复:

enter image description here

参考: 更新用户 - Microsoft Graph v1.0

© www.soinside.com 2019 - 2024. All rights reserved.