Other ways to get a Teams User Access Token?

Jeroen H 40 Reputation points
2024-02-28T15:27:12.53+00:00

Hi all, I'm making a Teams tab app and I followed this page about getting Teams User Access Tokens for one of the app's features. However, I would like to do it silently without the need of logging in. The only way I could find to get such a token is with the 'getTokenForTeamsUser' method from the @azure/communication-identity library (I'm using js). The method requires an Aad access token, an Entra access token in other words. I already tried getting an access token from:

  • The On-behalf-of flow: this token is invalid according to getTokenForTeamsUser. Raw error text: errorMsgWithOBOToken.txt
  • Microsoft Graph: this token can be generated from the same authcode that you use in the tutorial for the entra token, but is also not valid. Raw error text: errorMsgWithGraphToken.txt

All approaches have used the same scopes, and as such I don't really understand what else I could be missing. I haven't tried the MSAL token cache yet, but this still requires an initial ms login, which is not desirable if you're already in teams. Or is it possible to fetch the user account object from the Teams app libraries? What other way is there? I'd love to hear your experiences.

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
687 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,878 questions
{count} votes