Microsoft Teams, Fetch ALL chat messages with MS Graph API

%3CLINGO-SUB%20id%3D%22lingo-sub-2172777%22%20slang%3D%22en-US%22%3EMicrosoft%20Teams%2C%20Fetch%20ALL%20chat%20messages%20with%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172777%22%20slang%3D%22en-US%22%3E%3CP%3EI%20need%20to%20fetch%20all%20of%20the%20users'%20chats%20(even%20private%20ones)%20since%20the%20Admin%20had%20already%20given%20us%20their%20consent.%3C%2FP%3E%3CP%3EHow%20can%20I%20do%20that%20using%20Graph%20API%3F%3C%2FP%3E%3CP%3EWe%20are%20a%20bit%20confused%20between%20the%20Delegated%20vs.%20Application%20Permissions%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fchat-list%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dhttp%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20calling%20the%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%2Fusers%2F%26lt%3B%20user-id%20%26gt%3B%2Fchats%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efor%20a%20%3CEM%3Euser-id%3C%2FEM%3E%20different%20from%20mine%20(I%20am%20the%20admin)%20but%20it%20returs%20that%20the%20call%20is%20%3CEM%3Eunauthorized%3C%2FEM%3E%3C%2FP%3E%3CP%3ECan%20the%20Admin%20get%20Delegated%20Permissions%20through%20setting%20their%20org-wide%20policies%20appropriately%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2172777%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2173928%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%2C%20Fetch%20ALL%20chat%20messages%20with%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2173928%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F981344%22%20target%3D%22_blank%22%3E%40christosjubile%3C%2FA%3E%2C%20This%20question%20was%20already%20answered%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F66321833%2Fmicrosoft-teams-fetch-all-chat-messages-with-ms-graph-api%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F66321833%2Fmicrosoft-teams-fetch-all-chat-messages-with-ms-graph-api%3C%2FA%3E%26nbsp%3B%26nbsp%3BSo%20we%20are%20closing%20this%20issue%20here.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2173933%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%2C%20Fetch%20ALL%20chat%20messages%20with%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2173933%22%20slang%3D%22en-US%22%3ESorry%20my%20dear%20but%20the%20answer%20it%20was%20not%20sufficient%20enough%20but%20I%20had%20to%20assume%20it%20as%20a%20possible%20solution%20or%20a%20possible%20bug%2C%20the%20question%20remains%3A%20%22Is%20it%20possible%20for%20an%20admin%20to%20permit%20a%20third%20party%20application%20to%20fetch%20all%20the%20users%20private%20chat%20messages%3F%22%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2176081%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%2C%20Fetch%20ALL%20chat%20messages%20with%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2176081%22%20slang%3D%22en-US%22%3ECheck%20this%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fexport-teams-content%23how-to-access-teams-export-apis%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fexport-teams-content%23how-to-access-teams-export-apis%3C%2FA%3E%3CBR%20%2F%3EPossible%20with%20application%20permissions%20and%20it%20is%20protected%20API.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2177275%22%20slang%3D%22en-US%22%3ERe%3A%20Microsoft%20Teams%2C%20Fetch%20ALL%20chat%20messages%20with%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2177275%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F981344%22%20target%3D%22_blank%22%3E%40christosjubile%3C%2FA%3E%2C%26nbsp%3B%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Efor%20that%20API%20only%20delegated%20permissions%20can%20be%20enabled%20and%20it%20doesn't%20support%20application%20permissions.%20H%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Eence%20you%20cannot%20get%20other%20user's%20chat%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%3EMicrosoft%20will%20always%20focus%20on%20customer%E2%80%99s%20feedback%20and%20experience%2C%20some%20new%20features%20would%20be%20added%20to%20the%20services%20based%20on%20customers'%20feedback%20in%20the%20future%2C%20we%20also%20recommend%20you%20give%20your%20new%20idea%20in%20Teams%20UserVoice%20%3CA%20href%3D%22https%3A%2F%2Fmicrosoftteams.uservoice.com%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I need to fetch all of the users' chats (even private ones) since the Admin had already given us their consent.

How can I do that using Graph API?

We are a bit confused between the Delegated vs. Application Permissions

 

 

https://docs.microsoft.com/en-us/graph/api/chat-list?view=graph-rest-beta&tabs=http

 

 

 

I am calling the

 

 

/users/< user-id >/chats

 

 

for a user-id different from mine (I am the admin) but it returs that the call is unauthorized

Can the Admin get Delegated Permissions through setting their org-wide policies appropriately?

6 Replies

Hi @christosjubile, This question was already answered here. So we are closing this issue. 

Sorry my dear but the answer it was not sufficient enough but I had to assume it as a possible solution or a possible bug, the question remains: "Is it possible for an admin to permit a third party application to fetch all the users private chat messages?"

@christosjubilefor that API only delegated permissions can be enabled and it doesn't support application permissions. Hence you cannot get other user's chat 

Microsoft will always focus on customer’s feedback and experience, some new features would be added to the services based on customers' feedback in the future, we also recommend you give your new idea in Teams UserVoice here.

@Mamatha-MSFThow about the @Subba_Reddi_Tummuru answer? is it valid to get the message from export protected API which is proposed? https://docs.microsoft.com/en-us/microsoftteams/export-teams-content#how-to-access-teams-export-apis

@christosjubile Yes, you can get all messages using Teams Export API but, needs to have these permissions.