displayName returns "Undefined" in app.getContext() of Teams JS SDK

Testa 571 Reputation points
2023-07-30T14:45:40.4833333+00:00

Hello,

I tried to get "displayName" of users with Teams JS Library, but it returns "Undefined".

From the document below, I believe it just does not return "displayName", right?

https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/access-teams-context?tabs=Json-v2%2Cteamsjs-v2#get-context-by-using-the-microsoft-teams-javascript-library

Or is there any way to get "displayName" in app.getContext()?

(I know I can use GraphAPI to get it, but it would be easier to get displayName as well)

Microsoft Teams Development
0 comments No comments
{count} votes

Accepted answer
  1. Nivedipa-MSFT 3,646 Reputation points Microsoft External Staff Moderator
    2023-07-31T05:41:17.29+00:00

    We received a response from the engineering team stating, "This is by design. Teams has never returned the displayName in the app context."

    As a workaround, you can authenticate the user and retrieve their name from the auth token using the steps outlined in the following documentation:
    https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/tab-sso-overview

    The engineering team is considering this as a feature request.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.