Send messages in channel using Graph api

%3CLINGO-SUB%20id%3D%22lingo-sub-2492650%22%20slang%3D%22en-US%22%3ESend%20messages%20in%20channel%20using%20Graph%20api%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2492650%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20send%20message%20to%20teams%20channel%20through%20graph%20api%20and%20using%20python's%20msal%20library%20to%20get%20token.%20I%20am%20getting%20tokens%20but%20still%20receiving%20unauthorized%20access%20error%20while%20sending%20message.%20I%20have%20added%20permissions(delegated%20and%20application)%20as%20mentioned%26nbsp%3B%3CA%20title%3D%22graph%20api%20docs%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fchatmessage-post-replies%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%26nbsp%3B%26nbsp%3Balthough%20token%20received%20only%20shows%20application%20permission.%3CBR%20%2F%3EI%20am%20not%20sure%20what%20else%20I%20am%20missing%3B%20I%20went%20through%20lots%20of%20docs%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fhtml%2F%409839A717402516D64549B98324F4F0C1%2Fimages%2Femoticons%2Fsad_40x40_1.gif%22%20alt%3D%22%3Asad%3A%22%20title%3D%22%3Asad%3A%22%20%2F%3E%20but%20no%20luck.%20Any%20help%20will%20be%20highly%20appreciated.%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20You!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pritam2277_0-1624888062689.png%22%20style%3D%22width%3A%20421px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F291904i1B682338227C7A7A%2Fimage-dimensions%2F421x271%3Fv%3Dv2%22%20width%3D%22421%22%20height%3D%22271%22%20role%3D%22button%22%20title%3D%22pritam2277_0-1624888062689.png%22%20alt%3D%22pritam2277_0-1624888062689.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pritam2277_1-1624888108540.png%22%20style%3D%22width%3A%20468px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F291905iFA04C10E9753FE4C%2Fimage-dimensions%2F468x90%3Fv%3Dv2%22%20width%3D%22468%22%20height%3D%2290%22%20role%3D%22button%22%20title%3D%22pritam2277_1-1624888108540.png%22%20alt%3D%22pritam2277_1-1624888108540.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EReceived%20token%20and%20error%20message%20as%20below.%3C%2FP%3E%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3EDecoded%20Access%20Token%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%7B%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22aud%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%3C%2FA%3E%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22iss%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fsts.windows.net%2Fff9b87e3-***********************%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsts.windows.net%2Fff9b87e3-***********************%2F%3C%2FA%3E%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22iat%22%3A%201624887965%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22nbf%22%3A%201624887965%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22exp%22%3A%201624891865%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22aio%22%3A%20%22E2Zg******************%3D%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22app_displayname%22%3A%20%22********%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22appid%22%3A%20%22dc75307f-4*****************%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22appidacr%22%3A%20%221%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22idp%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fsts.windows.net%2Fff9b87e3-*************************%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsts.windows.net%2Fff9b87e3-*************************%2F%3C%2FA%3E%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22idtyp%22%3A%20%22app%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22oid%22%3A%20%222b5abfe6-********************%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22rh%22%3A%20%220.ARMA44eb_0jFPUuHg**************************.%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22roles%22%3A%20%5B%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22Teamwork.Migrate.All%22%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%5D%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22sub%22%3A%20%222b5abfe6-73df-4b9***********%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22tenant_region_scope%22%3A%20%22NA%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22tid%22%3A%20%22ff9b8************47b**%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22uti%22%3A%20%22cv5Y**************A%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22ver%22%3A%20%221.0%22%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22wids%22%3A%20%5B%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%220997a1d0*********************%22%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%5D%2C%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%22xms_tcdt%22%3A%201420304885%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%7D%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3EToken%20Expires%20at%3A%202021-06-28%2020%3A21%3A05%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%23999999%22%3E%7B'error'%3A%20%7B'code'%3A%20'UnknownError'%2C%20'message'%3A%20''%2C%20'innerError'%3A%20%7B'date'%3A%20'2021-06-28T13%3A51%3A08'%2C%20'request-id'%3A%20'2cc385c5-85e4-4fde-824c-399bac232e1e'%2C%20'client-request-id'%3A%20'2cc385c5-85e4-4fde-824c-399bac232e1e'%7D%7D%7D%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2492650%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

I am trying to send message to teams channel through graph api using python's msal library to get token. I am getting tokens but still receiving unauthorized access error while sending message. I have added permissions(delegated and application) as mentioned here  although token received only shows application permission.
I am not sure what else I am missing; I went through lots of docs:sad: but no luck. Any help will be highly appreciated.

Thank You!

 

pritam2277_0-1624888062689.png

pritam2277_1-1624888108540.png

 

Received token and error message as below.

Decoded Access Token
{
"aud": "https://graph.microsoft.com",
"iss": "https://sts.windows.net/ff9b87e3-***********************/",
"iat": 1624887965,
"nbf": 1624887965,
"exp": 1624891865,
"aio": "E2Zg******************=",
"app_displayname": "********",
"appid": "dc75307f-4*****************",
"appidacr": "1",
"idp": "https://sts.windows.net/ff9b87e3-*************************/",
"idtyp": "app",
"oid": "2b5abfe6-********************",
"rh": "0.ARMA44eb_0jFPUuHg**************************.",
"roles": [
"Teamwork.Migrate.All"
],
"sub": "2b5abfe6-73df-4b9***********",
"tenant_region_scope": "NA",
"tid": "ff9b8************47b**",
"uti": "cv5Y**************A",
"ver": "1.0",
"wids": [
"0997a1d0*********************"
],
"xms_tcdt": 1420304885
}
Token Expires at: 2021-06-28 20:21:05
{'error': {'code': 'UnknownError', 'message': '', 'innerError': {'date': '2021-06-28T13:51:08', 'request-id': '2cc385c5-85e4-4fde-824c-399bac232e1e', 'client-request-id': '2cc385c5-85e4-4fde-824c-399bac232e1e'}}}

0 Replies