microsoftgraph / microsoftgraph/msgraph-sdk-java
expand of appRoleAssignments on user get call yields no results
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 444
- Forks
- 154
- Merge medio
- 18 h 28 min
- PR fusionados (30 d)
- 4
Descripción
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_
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo las dos llamadas GET de usuario del issue con la expansión appRoleAssignments y compara sus respuestas con la solicitud separada de appRoleAssignments. Comprueba si el comportamiento de expansión documentado es compatible con el servicio Graph y con la versión 6.22.0 del SDK; se considera terminado cuando la solicitud combinada devuelve las asignaciones esperadas o se documenta la limitación.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100