How to get aadObjectId of Microsoft Personal Accounts which uses MS Teams
Asked Answered
C

0

8

We work on MS Teams bots. Each bot notification contains aadObjectId in request body by which we identify the user.

Sample Bot Request

{"name":"composeExtension/query","type":"invoke","timestamp":"2021-04-28T06:41:18.718Z","localTimestamp":"2021-04-28T12:11:18.718+05:30","id":"f:c3c988ef-b14b-b996-b3ec-cee22dbeb5ca","channelId":"msteams","serviceUrl":"https://smba.trafficmanager.net/in/","from":{"id":"29:1FKDpJ_2YcIMpBd94h8BABBpkrv_RVSSeeJ3qh8U3djsypgk2lnJxbq_Sd4eUVFE2lHXBuUBMQ_se7QEvYzTbtQ","name":"Test Account","aadObjectId":"7812b15f-6462-44ef-a772-d9012c55bf1c"},"conversation":{"conversationType":"personal","tenantId":"4d4f9f3f-2553-430b-b86b-442be9306e29","id":"a:1W4nBEGebG_h5wTFEGuyFYXr0_vCYTvg3-lIZ9uKaPFiDZmtU5FIA2PH880C09mrtxbqEeIJ-sPQvwy0qfDhmTOPuEGRtkoT7NGS1eTBHBfjWXWFMRgOK5yzsNMlL6i0d"},"recipient":{"id":"28:97f33763-604f-89ae-40b3-719c55e66177","name":"Test Bot"},"entities":[{"locale":"en-GB","country":"GB","platform":"Web","timezone":"Asia/Calcutta","type":"clientInfo"}],"channelData":{"tenant":{"id":"4d4f9f3f-2553-430b-b86b-442be9306e29"},"source":{"name":"compose"}},"value":{"commandId":"Contacts","parameters":[{"name":"initialRun","value":"true"}],"queryOptions":{"skip":0,"count":25}},"locale":"en-GB","localTimezone":"Asia/Calcutta"}

During initial authentication we store the user id. We use OAuth2.0 and the below Microsoft Graph API to get the user id.

https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http

We noticed that id returned in graph api and from bot framework is same for business(or Work) accounts.

However for personal accounts it is different

Sample Id's for reference

Work Account
From Graph API - id : 7812b15f-6462-44ef-a772-d9012c55bf1c
From Bot - aadObjectId : 7812b15f-6462-44ef-a772-d9012c55bf1c
Personal Account
From Graph API - id : 47268d7805746036
From Bot - aadObjectId : 6542b15f-7632-a772-44ef-d9012c55bf1c

So how to get the aadObjectId for personal users?

Creativity answered 28/4, 2021 at 8:15 Comment(3)
Is your personal account also added to the tenant?Affirmative
Its not my personal account. It is any random users accountCreativity
We have raised a bug on this and it is being tracked internally.Dacoit

© 2022 - 2024 — McMap. All rights reserved.