c# - Azure AD b2b "Read all users' basic profiles" permission
问题描述
I have delegated user permission User.ReadBasic.All
. In the documentation, it states this
"Allows the app to read a basic set of profile properties of other users in your organization on behalf of the signed-in user. This includes display name, first and last name, email address, open extensions and photo. Also allows the app to read the full profile of the signed-in user."
How can I get all users with basic profiles?
var accessToken = authContext
.AcquireTokenAsync(graphResourceId, new ClientCredential(clientId, secret))
.Result
.AccessToken;
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(requestMessage => {
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
return Task.FromResult(0);
}));
Can you please confirm my "Authority" URL is correct or not?
string authority = "https://login.microsoftonline.com/{tenantId}/common/oauth2/v2.0/token?&response_type=code&scope=openid%20profile%20User.Read%20User.ReadWrite%20User.ReadBasic.All";
AuthenticationContext authContext = new AuthenticationContext(authority);
var accessToken = authContext
.AcquireTokenAsync(graphResourceId, new ClientCredential(clientId, secret))
.Result
.AccessToken;
解决方案
You can hit the Graph API users/<email_id>
endpoint (https://graph.microsoft.com/v1.0/users/<email_id_of_the_user>
) with the proper Bearer token for getting the basic details of other users.
You can try that out in the Graph Explorer as well - https://developer.microsoft.com/en-us/graph/graph-explorer#
推荐阅读
- html - 如何在更改屏幕时隐藏导航并显示它?
- css - 有没有办法通过使用 CEF 来更改旧的 MFC 浏览器窗口?
- flutter - 如何使用计时器更新小部件
- node.js - Mongodb 聚合方面无法使用 _id
- javascript - 选择第一个监视器 Api google
- roku - 你如何在 Roku 的 SceneGraph 中调整 overhang.title 的位置
- sql - SQL在给定开始日期和年数的情况下获取每一年的开始日期和结束日期
- html - 容器内的行高表现不同
- docker - 从 docker stack 模式访问本地网络主机
- python - 无法获得 gunicorn 访问日志响应时间的毫秒级读数