Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!