Jun 28 2021 07:21 AM - edited Jul 14 2021 06:30 AM
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 docs . 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'}}}
Jul 05 2021 10:19 PM
Solution@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.
Jul 16 2021 02:36 AM
Jul 17 2021 06:08 AM
@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?
Jul 21 2021 11:24 AM - edited Jul 21 2021 11:25 AM
@Wajeed-MSFT While sending message to teams channel, I was getting error as protected api access denied. So I requested protected api access for my application. Microsoft teams has approved the access for application but they also mentioned and I quote "Application-only context sending of messages is only supported in teams which are in migration mode and requires Teamwork.Migrate.All. Refer to
Use Microsoft Graph to import external platform messages to Teams - Teams | Microsoft Docs for what migration mode means. "
Does it mean that it's not possible to send messages FROM APPLICATION to existing channels in team as it only support teams in migration mode?
Jul 27 2021 09:46 PM
@pritam2277 Yes, while using application permission for sending messages, you can't just send message until team is in migration state. Please use delegated flow(Get access on behalf of a user - Microsoft Graph | Microsoft Docs) .
Aug 12 2021 02:29 AM
Mar 12 2024 01:12 PM
Hi @HunaidHanfee-MSFT ,
Which particular permission should be assigned for replies to teams channel post. I am able to make a new post but not send a reply to one. Getting below error.
Error posting reply: {"error":{"code":"Unauthorized","message":"Message POST is allowed in application-only context only for import purposes.
Mar 13 2024 02:00 AM
Jul 05 2021 10:19 PM
Solution@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.