Get bearer token for "https://teams.microsoft.com/api/xx/xxx/xxxx-03/beta/users/...."
I am trying to get a federated user information without registering my application on external tenant. See the thread https://learn.microsoft.com/en-us/answers/questions/1166664/
I tried MS Teams Search API “https://teams.microsoft.com/api/mt/xxx/xxx/beta/users/<user-id>/externalsearchv3?includeTFLUsers=true”, after logging into MS Teams, in a Browser, toggling developers tools. API ran successfully and fetched the results as shown.
I then tried the same API in Postman and specified bearer tokens from the Team User logged in Developer Tools web page. It ran successfully there as well. Few questions here:
- How to use the same API in our client application to get information for external user?
- How do I get the bearer tokens? What’s the scope of bearer tokens here?
- AFAIK, Graph API is supposed to be the official Teams API by Microsoft. We are using Graph APIs to fetch user info from the tenant. Similar Graph API “https://graph.microsoft.com/beta/users/<user-id>/externalsearchv3” did not worked in Graph Explorer.
- We tried to specify the Bearer Tokens that we could retrieve with Graph APIs, scopes: ['https://graph.microsoft.com/User.Read.All'], and used them with Teams API, it failed with obvious reasons.
How can I use the MS Teams Search API "https://teams.microsoft.com/api/mt/...." in my client application? How can I get bearer tokens for MS Teams?
Get access token:
Also, To query a B2B user using the userPrincipalName, encode the hash (#) character. That is, replace the
%23. For example,
Also refer this thread which might help:
Thanks for the update, I have gone thorough the links previously, but both solutions require your app to be registered on external tenant and get info as per admin consent of that tenant, here I am trying to retrieve external user's information without registering my application on external tenant, I am trying to follow the same approach as MS teams while searching for an external user.
Did you try configuring your app as a multi-tenant app and then add your app to other tenant as an enterprise app and try to get user details?
Prasad, that's what I don't want. I want to retrieve external user's information without adding my application on external tenant. Just like MS teams does, you do not add MS teams to the tenant but still it gets the info for external user for you using API “https://teams.microsoft.com/api/mt/xxx/xxx/beta/users/<user-id>/externalsearchv3?includeTFLUsers=true”. I just wanna check how can I use this API in my application as it needs bearer token for MS Teams logged in user.
Okay. We will check this with engineering team and inform you if there is any way to do so.
Okay, we will check this with engineering team and update you if there is any way to do so.
Sign in to comment