I have created an application using graph API and I have assigned them permission - both delegated and application...
ServicePrincipal servicePrincipal = graphClient.servicePrincipals(resSerPrinId)
.buildRequest()
.get();
List<AppRole> appRoles = servicePrincipal.appRoles;
List<PermissionScope> scopes = servicePrincipal.oauth2PermissionScopes;
List<ResourceAccess> raList = new ArrayList<ResourceAccess>();
for (AppRole appRole : appRoles) {
ResourceAccess access = new ResourceAccess();
access.id = appRole.id;
access.type = "Role";
raList.add(access);
}
System.out.println("Roles added...");
for (PermissionScope permissionScope : scopes) {
ResourceAccess access = new ResourceAccess();
access.id = permissionScope.id;
access.type = "Scope";
raList.add(access);
}
System.out.println("Scopes added...");
RequiredResourceAccess reqResAccess = new RequiredResourceAccess();
reqResAccess.resourceAccess = raList;
reqResAccess.resourceAppId = resSerPrinAppClientId;
List<RequiredResourceAccess> rraList = new ArrayList<RequiredResourceAccess>();
rraList.add(reqResAccess);
Application application = graphClient.applications(clientAppObjId)
.buildRequest()
.get();
application.requiredResourceAccess = rraList;
graphClient.applications(clientAppObjId)
.buildRequest()
.patch(application);
Here in the code above, resSerPrinId is resource service principal Id which has app roles in manifest and a scope in "expose an api" section...
So I am pulling out appRoles and oauth2Permission from that resource service principal and sending them to client service principal...
In the UI I am seeing that the permissions do not have grant...
Is it possible to give them admin grant using some graph API or or manually loading these permission and then giving them admin grant...or do I need to always use the UI to do it...?
