This tool crawls all the chat threads from a teams channel by calling the API that Teams online uses.
Create a configuration file named teams-crawler.json
:
{
"teamId": "",
"channelId": "",
"token": ""
}
Field | Type | Description |
---|---|---|
teamId |
string | The if of a Team, can get from Microsoft Graph. |
channelId |
string | The id of a Teams Channel, can get from Microsoft Graph. |
token |
string | The access token, can get by inspect the traffic in Teams Online and get from the request header. (I do not find another easier way to get the token. I tried get an access token from Graph API, but it cannot work here...) |
run:
node index.js
The result will be saved to chatThreads.json
, like:
{
"chatThreads": [
...
]
}
This works by mimicing API calls between Teams Online and server. This need to:
-
Log on Teams Online
-
Get the
authtoken
from Cookies. with value like:Bearer={TOKEN}&Origin=https://teams.microsoft.com
. -
Get teams id, channel id using teams API
-
Send request to get first chat thread.
- URL: </api/csa-msft/api/v1/teams/{teamId}/channels/${channelId}?pageSize=20>
- method: GET
- headers:
- authorization:
Bearer {TOKEN}
- authorization:
This request contains 20 threads as
pageSize
specifies. This is the default age size of Teams Online. -
Send request to get the remaining threads. This is the same as the above step, with an additional header
x-ms-continuation
. It's value can be found in the response of the previous request keyedcontinuationToken
. Resend this repeatedly to get all the threads.