Forum Discussion
Sending message/replies to teams channel using graph api
I am trying to send message to teams channel using graph api and Python's msal library to get tokens. I have registered the app in Azure portal and added permission(delegated and application) to it as per https://docs.microsoft.com/en-us/graph/api/chatmessage-post-replies?view=graph-rest-beta&tabs=http . I am able to generate token, although tokens received only reflect application permission and not delegated permission. I am able to send messages using my username in graph explorer but NOT able to do it using my app.
I tried searching many docs/forums but no luck
; not sure what I am missing.
Below are received decoded token and error message:{
"aud": "https://graph.microsoft.com",
"iss": "https://sts.windows.net/ff9b87e***********************/",
"iat": 1624887965,
"nbf": 1624887965,
"exp": 1624891865,
"aio": "E2Z*************=",
"app_displayname": "MyApp",
"appid": "dc753**************",
"appidacr": "1",
"idp": "https://sts.windows.net/ff9b87e3-c54*******************/",
"idtyp": "app",
"oid": "2b5abfe6-7********************",
"rh": "0.AR*********************************************",
"roles": [
"Teamwork.Migrate.All"
],
"sub": "2b5abfe6-73*************************",
"tenant_region_scope": "NA",
"tid": "ff9b87e3-c5************************",
"uti": "cv5Yb******************",
"ver": "1.0",
"wids": [
"0997a1d0-0d1d-*****************"
],
"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'}}}
pritam2277 - You are currently using Get access without a user(Application permission). Application permissions are only supported for migration. Instead you should try delegated flow: Get access on behalf of a user. Please go though the documentation and you can try it using Postman or Fiddler.
You can also try Get started with Microsoft Graph and Python tutorial which shows fetching calendar information using Graph APIs.
Please let me know if you are still facing any issues.
8 Replies
- Wajeed-MSFT
Microsoft
pritam2277 - You are currently using Get access without a user(Application permission). Application permissions are only supported for migration. Instead you should try delegated flow: Get access on behalf of a user. Please go though the documentation and you can try it using Postman or Fiddler.
You can also try Get started with Microsoft Graph and Python tutorial which shows fetching calendar information using Graph APIs.
Please let me know if you are still facing any issues.
- pritam2277Copper ContributorThanks Wajeed-MSFT for reply. Will it be possible for you have a quick call with me?
- Wajeed-MSFT
Microsoft
pritam2277 - Unfortunatly no. Could you please share more specifics on issue which you are facing currently? Did you try Get started with Microsoft Graph and Python?