Get Teams SharePoint internal URLs but NOT using Graph

Pablo Glomby 186 Reputation points
2021-04-28T18:27:14.39+00:00

Hi!
I have a request. I have a C# desktop application. I cannot use Graph since I cannot force customers to register any application in the Azure server.
I need to know if there is a way to know the SharePoint URL for each Team that a user has.
I know that using graph it would be easier:
I would just call
https://graph.microsoft.com/v1.0/me/joinedTeams
and then
https://graph.microsoft.com/v1.0/groups/"+szTeamId+"/sites/root

But this is a completely different scenario.

I see there is something called "MS Teams native API" that is basically what the Teams.exe local project uses...
Is there anything equivalente to Graph but using this undocumented API?

All I have that may be useful is:

  • I assume that the local Teams application may be installed
  • I have the user name and password that can be used to login to www.office.com
  • I can use CSOM API

I was curious to see if this URL map can be stored in %AppData%\Microsoft\Teams but I did not find it.
Using fiddler to inspect the HTTP traffic of Teams.exe does not provide anything useful.

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,113 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.
3,295 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,616 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jerryzy 10,571 Reputation points
    2021-04-29T06:48:18.873+00:00

    Hi @Pablo Glomby ,

    SharePoint CSOM/Rest API can only get the SharePoint site groups.

    For the joined Teams and the Group based site url, it's necessary to use Graph API.

    And in the Graph API, it's necessary to register a Azure AD App, using only username and password, it's not supported to authenticatio user, here is a similiar question for your reference:

    Is there way to authenticate to Graph API using Username and Password without Application Registration in Azure AD

    A different point in the request would be using /users/{user-id}/joinedTeams instead of /me as using the app-only permission, /me is not available as it's not a real user.

    Here is a code demo about register Azure AD App and connect with C# code, please refer:

    How To Access Microsoft Graph API In Console Application

    Thanks
    Best Regards


    If the response 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.

    0 comments No comments

  2. Pablo Glomby 186 Reputation points
    2021-04-29T13:11:24.333+00:00

    Thanks Jerryzy-MSFT for your answer.
    As I said, as my application may access several tenants and it's really a problem asking each customer to register an application, I really need to avoid registering an application.
    I've researched more and I saw that when you have the MS Teams installed (desktop application) the token is stored in a sqlite DB that is in %AppData%\Microsoft\Teams\Cookies.
    Here if you rename this file as .db and you browse this using an Sqlite client you will find that there is a cookies table and inside this table there is an SSOAUTHCOOKIE value that contains the authentication token used by the desktop teams application and inside this token (if I analyze it) the client app id is 1fec8e78-bce4-4aaf-ab1b-5451cc387264 that is "Microsoft Teams" enterprise application in the Azure server. The token has: "scp": "user_impersonation" . I tried to use this client app id with ADAL to see if I can get the graph token but I could not.
    Can I use this token to get a graph token in any way?

    This local desktop Teams program uses the "MS Teams native API":
    https://digitalworkplace365.wordpress.com/2021/01/04/using-the-ms-teams-native-api-end-points/#more-330

    I wonder why MS does not document it... there is really a Teams API.

    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.