What are the permission needed for an Service Principal to call AD graph API: Get Objects By Object Ids:
POST https://graph.windows.net/{tenantID}/getObjectsByObjectIds?api-version=1.6
I set up an App with
Application Permission: Read directory data.
Delegated Permission:
Read Directory data Read and write directory data Read all users full profile Sign in and read user profile.
But I am receiving Forbidden ( status code 403) while making the API call:
Also i got access token through this code:
string authority = "https://login.microsoftonline.com/" + "microsoft.com";
AuthenticationContext ac = new AuthenticationContext(authority);
ClientCredential cr = new ClientCredential("Appid", "Cred");
string OfficeUrl = "https://graph.windows.net";
AuthenticationResult authenticationResult = ac.AcquireTokenAsync(OfficeUrl, cr).Result;
string token = authenticationResult.AccessToken;
// string token = this.SetAuthorizationToken();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);