Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only NULL on getMember from groups. #1561

Closed
MikeAuerAN opened this issue Jul 27, 2024 · 2 comments
Closed

Only NULL on getMember from groups. #1561

MikeAuerAN opened this issue Jul 27, 2024 · 2 comments
Labels
no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@MikeAuerAN
Copy link

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_
@MikeAuerAN MikeAuerAN added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 27, 2024
@Ndiritu Ndiritu removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Aug 8, 2024
@Ndiritu Ndiritu assigned Ndiritu and andrueastman and unassigned Ndiritu Aug 8, 2024
@andrueastman
Copy link
Member

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();

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed type:bug A broken experience labels Aug 9, 2024
@andrueastman andrueastman removed their assignment Aug 9, 2024
@andrueastman andrueastman added the type:question An issue that's a question label Aug 9, 2024
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

3 participants