在MS Graph Java SDK 6.1中,我正在尝试确定给定应用程序的所有者。我有应用ID。 我正在尝试使用此示例代码
// Fetch the owners of the application
List<DirectoryObject> owners = graphClient
.applications(applicationId)
.owners()
.buildRequest()
.get()
.getCurrentPage();
applications不再采用参数
applicationId,applicationsbybyappid(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
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Application app = graphClient.applicationsWithAppId("{appId}").get();
使用应用程序对象ID获取所有者
DirectoryObjectCollectionResponse owners = graphClient.applications().byApplicationId(app.getId()).owners().get();