How to quickly get the Group ID for an Office 365 Group

Microsoft Graph typically requires us to use the Group ID when working with O365 groups and modern sites. But Group ID can be tricky to find since it is rarely displayed. Here are some ways I found to quickly get hold of it during when experimenting with MS Graph:

1. The group ID is made available on our trusty old friend _spPageContextInfo  in the group’s SharePoint site. Knowing this we can easily find it by going to the site and type _spPageContextInfo.groupId  in the JS console. _spPageContextInfo is however not available on modern pages, but you can go to a page that is not modern such as Site Settings to find it.

2. Using Graph Explorer we can query for the group. By default mailNickname is used for the site URL. So if the site URL is  then GET$filter=mailNickname eq 'MyTeamSite'&$select=id  will give you the Group ID. Note that mailNickname is  not guaranteed to be the same as the site URL, for example if you have changed the site URL.

3. Group ID is also hidden deep in the page source of modern sites. To find it you can view the page source (CTRL+U) and search for spPageContextInfo. Triple click the paragraph you found to select it, copy the paragraph to the clipboard, open the JS console and paste it between two brackets { CTRL+V } and press enter. Now you can easily inspect the object and find the group id.

4. We can actually get to the page context object on modern pages too, but it is hidden deep down: window.spModuleLoader._bundledComponents["b6917cb1-93a0-4b97-a84d-7cf49975d4ec"].PageManager._instance.pageContext.legacyPageContext.groupId (FYI: The GUID here refers to the web scoped feature for “modern” pages.). I made a bookmarklet to make it easier to access:  javascript:void%20function(){alert(window.spModuleLoader._bundledComponents[%22b6917cb1-93a0-4b97-a84d-7cf49975d4ec%22].PageManager._instance.pageContext.legacyPageContext.groupId)}();

This entry was posted in Tips and tagged , , , , . Bookmark the permalink.

2 Responses to How to quickly get the Group ID for an Office 365 Group

  1. Pingback: Find O 365 group Id | soumyabhatta

  2. Shane Ryans says:

    Hi, you can also get the connected group ID from a SharePoint site via REST:

    In the results, the property “GroupId” contains the id.

    A further option: when o365 groups are added to SharePoint site groups, the resolved user login name contains the group ID e.g. for members: “0oc|federateddirectoryclaimprovider|25cbc11a-a123-4e55-9f46-5e180a7cc3f6”, and owners: “0oc|federateddirectoryclaimprovider|25cbc11a-a123-4e55-9f46-5e180a7cc3f6_o”

Leave a Reply

Your email address will not be published. Required fields are marked *