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',
},
});
I would suggest to check Azure AD portal: portal.azure.com/#view/Microsoft_AAD_UsersAndTenants/… try to add column PreferredLanguage and check if the language is set. If not, it can indicate some issue in Azure AD, not with the Graph API and permissions.