Reputation: 150
I cannot seem to be able to find the current user's username using the Microsoft Teams JS library. I am always given an empty value.
Here are the properties of the variable context
in
window.microsoftTeams.getContext(function(context){
// my stuff
}
channelId
, isFullScreen
, locale
, teamId
, theme
are provided, and once I finish configuring my tab and I try to edit it, so is the entityId
I provided.
However, the upn
property is always empty.
Is it caused by the fact that I'm side-loading my package or is it caused by something else ? Did anyone manage to get an user's username ?
Upvotes: 0
Views: 398
Reputation: 150
It seems that the documentation is partly outdated. In my manifest needsIdentity
was set to true
in my manifest but it didn't have any effect.
I searched in the schema reference for the manifest and found out about the permissions
array, in which you can put identity
and messageTeamMembers
.
After adding that to my manifest, the upn
is correctly provided in the context.
Upvotes: 1
Reputation: 28
Please check your manifest to see if you've set needsIdentity. From the MSDN Context page. Please validate that this answered your question! Thanks.
upn?: string The current user's upn. As a malicious party can host content in a malicious browser, this value should only be used as a hint as to who the user is and never as proof of identity. This field is only available when needsIdentity is set in the manifest.
Upvotes: 0