如何找到应用程序的所有者

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

在MS Graph Java SDK 6.1中,我正在尝试确定给定应用程序的所有者。我有应用ID。 我正在尝试使用此示例代码

// Fetch the owners of the application List<DirectoryObject> owners = graphClient .applications(applicationId) .owners() .buildRequest() .get() .getCurrentPage();

wower,
applications
不再采用参数

applicationIdapplicationsbybyappid(appid)没有方法ownowners().。 我的所有搜索都返回了上述代码,因此很明显,SDK最近发生了变化。 SDK文档中的样本也没有处理此样本。 我还尝试了以下代码,其中SDK确实具有getowners

方法,但是尽管应用程序明确指定了多个所有者,但它总是返回null。

ApplicationCollectionResponse resp = graphClient.applications().get(requestConfiguration -> { requestConfiguration.queryParameters.select = new String[] { "id", "displayName", "appId", "passwordCredentials" }; }); results = new ArrayList<>(); List<Application> apps = resp.getValue(); while (apps != null && apps.size() > 0) { for (Application app : apps) { // Fetch the owners of the application if (app.getOwners() != null) { for (DirectoryObject dirobj : app.getOwners()) { logger.debug("App {} has owner {}", app.getDisplayName(), dirobj.getId()); } }

我害怕需要两个步骤:

通过
appId
microsoft-graph-api azure-sdk-for-java
1个回答
0
投票
获取应用程序

GraphServiceClient graphClient = new GraphServiceClient(requestAdapter); Application app = graphClient.applicationsWithAppId("{appId}").get();
  1. 使用应用程序对象ID获取所有者
DirectoryObjectCollectionResponse owners = graphClient.applications().byApplicationId(app.getId()).owners().get();
    
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.