I am trying to create a security group in my azure AD directory and add b2c user (who has logged in) to that group.
msRestAzure.loginWithServicePrincipalSecret('72a3198b-', '-FvUZZ4G', tenantId, { tokenAudience: 'graph' }, function (err, credentials, subscriptions) {
if (err) console.log("error: " + err);
else {
console.log(util.inspect(credentials));
}
var client = new graphRbacManagementClient(credentials, tenantId);
client.groups.list({}, function(err, result){
if(err){
console.log('Could not list groups', err)
}
else {
console.log("result: " + result);
}
})
I have enabled the API permission on Azure....
Although I authenticate using my SP successfully, i get a 403 back in response whether I try to create a new group or list the existing groups etc.
Any ideas on what I am doing wrong here?
UPDATE: I changed the code and used msRestAzure.loginWithUsernamePassword
instead. The username and password I used was for a user with Admin privilege. After the change, the code worked and created/Listed the group. So my guess is, the SP needs some sort of a Access/API permission that I haven't enabled. I just don't know what..