I have written a small snippet to fetch all the service principals using Azure Java SDK. Getting this exception. What privileges do i need to give for this sdk call?
"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(
"<CLIENT_ID>", "<TENANT_ID>",
"<CLIENT_SECRET>", AzureEnvironment.AZURE);
Authenticated authenticated = Azure.configure().withLogLevel(LogLevel.NONE)
.authenticate(credentials);
PagedList<ServicePrincipal> servicePrincipals = authenticated.servicePrincipals().list();
servicePrincipals.stream().forEach(principal -> System.out.println(principal.id()));
I found what the problem is.
Whenever you try to fetch Service Principal using id it internally fetches all service principals and returns the specific service principal with that id.
I tried to fetch using getByName and it worked fine.