Microsoft Graph-作为Azure AD管理员,您如何为其他用户获取有效的访问令牌
如果我理解了用户Microsoft Graph-作为Azure AD管理员,您如何为其他用户获取有效的访问令牌,azure,azure-active-directory,microsoft-graph-api,microsoft-graph-sdks,Azure,Azure Active Directory,Microsoft Graph Api,Microsoft Graph Sdks,如果我理解了用户@marclafler的响应:,如果您是Azure AD管理员并且希望使用Microsoft Graph API重置另一个用户的密码,那么您需要为具有目录.accessUser.All权限的用户提供有效的访问令牌,然后您可以更新用户的密码配置文件 问题:使用Microsoft Graph,作为Azure广告管理员,我们如何为其他用户获取访问\u令牌 我的应用注册的身份验证页面: 如果您是Azure AD管理员并希望使用Microsoft Graph API重置其他用户的密码,则只
@marclafler
的响应:,如果您是Azure AD管理员
并且希望使用Microsoft Graph API
重置另一个用户的密码,那么您需要为具有目录.accessUser.All
权限的用户提供有效的访问令牌
,然后您可以更新用户的密码配置文件
问题:使用Microsoft Graph,作为Azure广告管理员,我们如何为其他用户获取访问\u令牌
我的应用注册的身份验证页面:
如果您是
Azure AD管理员
并希望使用Microsoft Graph API重置其他用户的密码,则只需获取管理员帐户本身的令牌,而不是要更改的用户
在这种情况下,您可以使用
1.在您的广告应用程序中,添加以下权限->单击授予xxx管理员许可
按钮
2.在浏览器中使用下面的url登录您的管理员帐户
https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize?
client_id=<client-id>
&response_type=code
&redirect_uri=<redirect_uri>
&response_mode=query
&scope=https://graph.microsoft.com/.default
&state=12345
我尝试了上面
步骤2
中的URL,首先输入我注册应用的有效租户id和客户端id。对于重定向URI,我的应用程序正在使用http://localhost
,所以我在你的URL中使用了http://localhost
。但是我收到了错误消息AADSTS50011:请求中指定的回复URL与为应用程序配置的回复URL不匹配:“我的客户端id在这里”…
我甚至尝试过,但仍然出现了相同的错误。@nam你能在我的帖子末尾显示你的应用程序注册页面的Authentication
截图吗,我刚刚添加了您要求的屏幕截图。此外,我正在使用Microsoft Graph SDK和授权代码提供程序。在SDK示例中,您在哪里使用access\u token
?@nam 1。我假设您的应用程序不是公共客户端,因此您需要添加Web
类型重定向url,单击添加平台
->Web
->输入http://localhost
,然后重试步骤2。2.sdkAuthorizationCodeProvider
自动使用身份验证代码流,无需手动使用access\u令牌。@是的,可以。
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithRedirectUri(redirectUri)
.WithClientSecret(clientSecret) // or .WithCertificate(certificate)
.Build();
AuthorizationCodeProvider authProvider = new AuthorizationCodeProvider(confidentialClientApplication, scopes);
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var user = new User
{
PasswordProfile = new PasswordProfile
{
ForceChangePasswordNextSignIn = true,
Password = password,
}
};
await graphClient.Users[userId]
.Request()
.UpdateAsync(user);