I’ve been trying to access Microsoft Graph data from an Azure enterpise connection. I can access the openid email and profile just fine, I’ve managed to get the groups through use of a rule, but can’t seem to access any Microsoft Graph data.
I’m assuming I need a rule to do this, but I just can’t work it out.
My Rule is as follows:
function (user, context, callback) {
const namespace1 = 'http://schemas.microsoft.com/ws/2008/06/identity/claims/';
const ns2 = 'https://graph.microsoft.com';
const namespace = 'myconnection';
context.idToken[namespace + 'department'] = user.department;
context.idToken[namespace + 'roles'] = namespace1.roles;
context.idToken[namespace + 'jobTitle'] = user.jobTitle;
context.idToken[namespace + 'groups'] = user.groups; // this will add groups to the token
const assignedRoles = (context.authorization || {}).roles;
let idTokenClaims = context.idToken || {};
let accessTokenClaims = context.accessToken || {};
idTokenClaims[`${namespace1}/role`] = assignedRoles;
accessTokenClaims[`${namespace1}/role`] = assignedRoles;
context.idToken = idTokenClaims;
context.accessToken = accessTokenClaims;
return callback(null, user, context);
}
Can anyone point me in the right direction?