Check if a given SharePoint site belongs to Teams (SharePoint REST API, or CSOM)

Pablo Glomby 186 Reputation points
2021-03-17T16:10:14.627+00:00

Hi!
I cannot use Microsoft Graph (else it would be easy) because I cannot get the Graph Token (I use the SharePointOnlineCredentials with username/password).
So all I can use is CSOM and the REST API.

Right now I get the frequent sites using this REST API:
https://<your_tenant>/_vti_bin/homeapi.ashx/sites/recent?SPHome-ClientType=SharePointIOS&mostRecentFirst=true&start=0&count=100

It returns the recent sharepoint sites including those belonging to Teams. I need to know if a given site belongs to Teams or not.
I have read that using the WebTemplate value would be enough (if it is Group) but I discovered that I can manually create a SP site and it can hold this value.

Is there a reliable way to know if a given site is used in Teams?
Thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,612 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,843 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,573 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Trevor Seward 11,681 Reputation points
    2021-03-17T16:25:59.967+00:00

    Using a username and password is considered insecure and you should switch to Client ID + Certificate or less preferably, Secret. The Graph API is how you need to pull this info.

    0 comments No comments

  2. MichaelHan-MSFT 18,016 Reputation points
    2021-03-18T06:37:30.273+00:00

    Hi @Pablo Glomby ,

    Using SharePoint Rest Api or CSOM, we cannot check if the site is used in Teams. As you said, we can only get the WebTemplate value. But that's not enough.

    As far as I know, when a site is used in Teams, the assosiated M365 group will have Teams connected. You can identify go to admin center> Groups>there you can see Teams status and symbol to identify that SharePoint site is used in Microsoft Teams. See image below for your reference.

    79026-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.