java - 使用 UsernamePasswordCredential 提供程序列出 Azure AD
问题描述
我正在使用 UsernamePasswordCredential 提供程序连接到 AAD 并使用 msgraph-sdk-java ( https://github.com/microsoftgraph/msgraph-sdk-java ) 获取用户,代码如下:
final UsernamePasswordCredential usernamePasswordCredential = new UsernamePasswordCredentialBuilder()
.clientId("client_id")
.username("user_name")
.password("password")
.build();
final TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(Arrays.asList("https://graph.microsoft.com/.default"), usernamePasswordCredential);
final GraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider(tokenCredentialAuthProvider)
.buildClient();
UserCollectionPage userCollectionpage = graphClient.users().buildRequest().get();
我收到以下错误:
java.io.IOException:java.util.concurrent.ExecutionException:com.azure.core.exception.ClientAuthenticationException:无法使用用户名和密码获取令牌
知道我是否需要在天蓝色的活动目录中配置一些东西吗?
解决方案
推荐阅读
- javascript - object 选项中的对象
- regex - 通过用括号括起来使区号(电话号码的前 3 位)突出来打印电话号码的命令
- reactjs - 创建 React Elements 的引用并像变量一样使用它
- c++ - 如何以有效的方式从函数返回值?(c++)
- python - 根据条件从当前行和上一行中的值创建列表
- arrays - RESB:声明和填充未初始化的数据
- python - opencv python错误:断言失败:size.width>0&&size.height>0
- python - 当 Cron 执行 selenium 时,geckodriver 的路径是什么
- c++ - 将二叉树的高度计算为 void 函数
- unity3d - 为什么在 Unity 车轮对撞机上侧向轮胎打滑与前向打滑分开?