My app on Microsoft Teams is using the consent flow to get the permissions from a user. Then with the access token returned by Microsoft, the app is trying to fetch the profile of the user using the /v1.0/me
route. But for many users the preferredLanguage
field in the profile object is null
, only in some users the filed is returning a language. My app needs the preferred language of the user to show a translated version of the app.
I am requesting the following scopes from Microsoft.
- User.Read
- TeamsActivity.Send (not related to this issue)
- offline_access (for refresh token)
Following is the code for the request for fetching the profile.
const { data, status } = await axios({
method: 'GET',
url: `https://graph.microsoft.com/v1.0/me?$select=id,mail,displayName,givenName,businessPhones,preferredLanguage`,
headers: {
Authorization: `Bearer ${accessToken}`,
ConsistencyLevel: 'eventual',
},
});
Go to Azure Portal -> Users -> Select the user -> Overview -> Properties
Initially I got the
preferredLanguage
as null while querying the user:Note that: Some user properties/details cannot be updated directly from the Azure Portal, make use of Microsoft Graph API to update the
preferredLanguage
property.After refreshing the user page, the
preferredLanguage
property is updated:Now when I used the same query to fetch the user details, the
preferredLanguage
is displayed with the value: