Only NULL on getMember from groups.
MikeAuerAN opened this issue · 2 comments
Describe the bug
I want to read all Members of a specific group of our M365 Tenant. Therefore i set the Permissions to Group.Read.All, GroupMember.Read.All, User.Read.All and created this Request:
$tokenRequestContext = new ClientCredentialContext(
json_decode($secret, true)['tenant_id'],
json_decode($secret, true)['client_id'],
json_decode($secret, true)['client_secret']
);
$scopes = [json_decode($secret, true)['scope']];
$graphServiceClient = new GraphServiceClient($tokenRequestContext);
try {
$groups = $graphServiceClient->groups()->get()->wait();
} catch (ApiException $ex) {
dd($ex->getError()->getMessage());
}
foreach($groups->getValue() as $group)
{
if ($group->getDisplayName() == $this->m365group)
{
$groupMember = $group->getMember();
}
}
The Request and Connection just works fine i can test this by providing a non exsisting group or removing the Privileges wich produces an error. Also If i fetch any other data like getId()
or getDisplayName()
it just works and the data is Displayed. But everytime i use getMember()
or getOwner()
as result i get null
When Using https://developer.microsoft.com/en-us/graph/graph-explorer with the same values everything just works fine.
Expected behavior
Retrieving any Kind of LIST or Array with the group Members.
How to reproduce
Call getMember()
on a Group object.
SDK Version
2.12.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
- Framework: Laravel 11 with Livewire 3
### Other information
_No response_
Thanks for raising this @MikeAuerAN
When Using https://developer.microsoft.com/en-us/graph/graph-explorer with the same values everything just works fine.
Any chance you can share the request you are making when using the graph explorer to help us understand this better?
As the members are relationships in the group entity, to retrieve them, I believe you would need to make subsequent call using the group id to retrieve these relationships.
List members - https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=php
$result = $graphServiceClient->groups()->byGroupId('group-id')->members()->get()->wait();
List owners - https://learn.microsoft.com/en-us/graph/api/group-list-owners?view=graph-rest-1.0&tabs=php
$result = $graphServiceClient->groups()->byGroupId('group-id')->owners()->get()->wait();
If you wish to have the members in the same request, you would probably need to specify a $expand parameter in the request.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GroupsRequestBuilderGetRequestConfiguration();
$queryParameters = GroupsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->expand = ["members"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->groups()->get($requestConfiguration)->wait();
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.