Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
MemberOf in Graph Me api azure AD

I am trying to get the member groups of the user to whom user belongs using azure graph api but it is not returning memberof in the api. I am using auth0 for the authentication.

Here is the java script code which I am using.

function(accessToken, ctx, cb) {
const jwt = require('jsonwebtoken@7.1.9');
console.log('azure - retrieve user profile');
// Retrieve the profile from Azure
request.get(
'https://graph.microsoft.com/v1.0/me?$select=id,mail,givenName,surname,userPrincipalName,otherMails,department,memberOf', {
  headers: {
    'Authorization': 'Bearer ' + accessToken,
  },
  json: true
},
function(e, r, profile) {
  if (e) {
    console.log('azure - error while retrieving user profile:');
    console.log(e);
    return cb(e)
  }
  if (r.statusCode !== 200) {
    console.log('azure - error while retrieving user profile: ' + r.statusCode);
    return cb(new Error('StatusCode: ' + r.statusCode));
  }
  console.log('azure - retrieved user profile.');
  // Get the tenant id from the access token
  let decodedToken = jwt.decode(accessToken);
  let auth0Profile = {
    user_id: profile.id,
    given_name: profile.givenName,
    family_name: profile.surname,
    email: profile.mail || profile.otherMails[0] || profile.userPrincipalName,
    email_verified: true,
    name: profile.givenName + ' ' + profile.surname,
    tenant_id: decodedToken.tid,
    identification_value: decodedToken.tid,
    user_principal_name: profile.userPrincipalName,
    user_department: profile.department,
    user_member: profile.memberOf
   };
  cb(null, auth0Profile);
  }
  );
  }

I have added scope (User.Read Directory.Read.All) in Auth0 for the api call. Can some one let me know why I am not getting memberOf?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to get member groups of the user, along with multiple attributes, the query will not return the expected results.

I tried checking the same query in Microsoft Graph Explorer.

'https://graph.microsoft.com/v1.0/me?$select=id,mail,givenName,surname,userPrincipalName,otherMails,department,memberOf'

Even for that, except memberOf, all objects displayed:

enter image description here

For getting memberOf, you have to query separately like below:

https://graph.microsoft.com/v1.0/me/memberOf

enter image description here

So, for the workaround, you can make use of the above query by giving it separately without querying with other attributes.

Also please make sure to add GroupMember.Read.All permissions in the scope as mentioned in this Microsoft Doc.

Please find below links if they are helpful: Ref1, Ref2

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda