Office 365 Groups is developed with collaboration in mind. It becomes a base service for most of existing Office 365 tools that we use already ( like writing documents, planner plans, calendar meetings, teams chat and exchange mail), so finding which unified groups a user is a member of is inevitable in many scenarios.
The Microsoft Graph Api endpoint https://graph.microsoft.com/v1.0/me/memberOf gets and return all the groups where a current user is memberOf. But it returns not only the unified groups, it also lists security groups and dynamic groups. So, you need to apply proper filter to get only Office 365 groups using memberOf endpoint.
Retrieve Office 365 Groups in which current user is a member of
The following API returns all the unified groups in which I am member of.
https://graph.microsoft.com/v1.0/me/memberOf/$/microsoft.graph.group?$filter=groupTypes/any(a:a eq 'unified')
Find Office 365 Groups where an user is a member of
You can also use the same memberOf endpoint to retrieve all the unified groups where a specific user is a member. You need to just replace the /me/ part in the above url with the user’s id /users/<user-id>/
https://graph.microsoft.com/v1.0/users/<user-id>/memberOf/$/microsoft.graph.group?$filter=groupTypes/any(a:a eq 'unified')
Note: You can call the memberOf endpoint without Admin Consent after applying unified filter and adding extra parameter (/$/microsoft.graph.group?$filter=groupTypes/any(a:a eq ‘unified’)) in memberOf endpoint url. If you call without this filter, you will receive the following Access Denied error when you don’t have proper admin consent.
"error": { "code": "Authorization_RequestDenied", "message": "Insufficient privileges to complete the operation.", }
Is there any way to get office 365 groups, where i'm a member and owner as well, instead only a member.
I think you can't get this result by calling a single graph api endpoint. You have to first get all groups where an user is memberof and iterate all groups and get owners for every group and check the user exists in the owners list or not – hope you already know this approach.