microsoftgraph / microsoftgraph/msgraph-sdk-java

expand of appRoleAssignments on user get call yields no results

未关闭
#2,242 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Needs: Attention :wave: type:question
主要语言
Java
星标
444
派生
154
平均合并
18 小时 28 分钟
30 天内合并 PR
4

描述

Describe the bug

I was trying to get a user together with it's appRoleAssignments in one call. The documentation is pointing out that the expand feature for appRoleAssignments is supported. But it doesn't work.

Expected behavior

I would expect the expand to return results.

How to reproduce
            User user = graphClient.usersWithUserPrincipalName(username).get(
                rc -> {
                    rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
                    rc.queryParameters.expand = new String[]{"appRoleAssignments"};
                }
            );

or

graphClient.users().byUserId(username).get(
                rc -> {
                    rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
                    rc.queryParameters.expand = new String[]{"appRoleAssignments"};
                }
            );
SDK Version

6.22.0

Latest version known to work for scenario above?

No response

Known Workarounds

For now I have to write this code to get it done:

            var user = graphClient.usersWithUserPrincipalName(username).get(
                rc -> rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"}
            );
            user.setAppRoleAssignments(getAllAppRoleAssignments(user.getId())); // an 'expand' of appRoleAssignments in the above call gave an empty array :| ...
            return user;

    private List<AppRoleAssignment> getAllAppRoleAssignments(String userId) {
        var result = new ArrayList<AppRoleAssignment>();
        var page = graphClient.users().byUserId(userId).appRoleAssignments().get();
        while (page != null) {
            result.addAll(Optional.ofNullable(page.getValue()).orElse(emptyList()));
            var odataNextLink = page.getOdataNextLink();
            if (StringUtils.isBlank(odataNextLink)) {
                break;
            } else {
                page = graphClient.users().byUserId(userId).appRoleAssignments().withUrl(odataNextLink).get();
            }
        }
        return result;
    }
Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用 appRoleAssignments 展开来重现 issue 中的两个用户 GET 调用,并将它们的响应与单独的 appRoleAssignments 请求进行比较。检查 Graph 服务和 SDK 版本 6.22.0 是否支持文档中所述的展开行为;当组合请求返回预期的分配结果,或该限制已被记录时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。