Reputation: 3
I want to list users in a domain as defined in google. I saw that it's available through the Google Admin Directory SDK. Although, I couldn't find any examples or documentation how can I use it in Java. I already have got the authorization part. I'm just not sure which objects should I use from the API and how.
Thanks!
Upvotes: 0
Views: 2353
Reputation: 1196
Here is an example with the relevant imports
From the docs (https://developers.google.com/admin-sdk/directory/v1/reference/users/list)
As an account administrator, you can also use the my_customer alias to represent your account's customerId
import java.io.IOException;
import java.util.List;
import com.google.api.services.admin.directory.Directory;
import com.google.api.services.admin.directory.model.User;
import com.google.api.services.admin.directory.model.Users;
public static List<User> listUser(Directory directory) throws IOException {
Users users = directory.users().list().setCustomer("my_customer").execute();
return users.getUsers();
}
Upvotes: 2
Reputation: 1474
I have answered a similar question at GoogleApps Directory APIs To Manage Users
You should try out the java client library.
https://developers.google.com/admin-sdk/directory/v1/api-lib/java
It has a quickstart for directory API in Java, which should help you set up and get started.
Additionally, here is the javadoc reference for this specific API
https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/java/latest/
Upvotes: 0