[英]How to pull more than 500 user objects from my domain?
I am trying to pull about 20,000 users from my Google domain. 我正试图从我的Google网域中吸引大约20,000个用户。 However, i know that Google only has a limit of about 500 users for a pull request. 但是,我知道Google的拉取请求只有大约500个用户限制。 I know about the pageToken stuff, but the documentation for it online is terrible. 我知道pageToken的内容,但是在线获取它的文档非常糟糕。 Can someone show me how to use the pageToken? 有人可以告诉我如何使用pageToken吗? Please keep in mind i am using the google client libraries. 请记住,我正在使用Google客户端库。 This is what my code looks like so far: 到目前为止,这是我的代码:
@Test
public void paginationTest() throws IOException, NullPointerException, GeneralSecurityException {
try {
Directory directory = GCAuthentication.getDirectoryService("xxx", "vvv", dddd);
Directory.Users.List list = directory.users().list().setOrderBy("email").setMaxResults(500).setDomain("dev.royallepage.ca");
do {
com.google.api.services.admin.directory.model.Users users = list.execute();
java.util.List<User> uL = users.getUsers();
//uL.addAll(users.getUsers());
//list.setPageToken(list.getPageToken());
System.out.println(uL.size());
}while (list.getPageToken() != null && list.getPageToken().length() > 0);
}catch(NullPointerException e) {
}
} }
Please advise what i am doing wrong! 请告知我我做错了! Thanks, 谢谢,
Mesam 梅萨姆
You will have to create a function that will get the pageToken
variable then call another request including the nextPageToken
. 您将必须创建一个将获取pageToken
变量的函数,然后调用另一个请求,包括nextPageToken
。
Use the
pageToken
query string for responses with large number of groups. 将pageToken
查询字符串用于具有大量组的响应。 In the case of pagination, the response returns thenextPageToken
property which gives a token for the next page of response results. 在分页的情况下,响应返回nextPageToken
属性,该属性为响应结果的下一页提供令牌。 Your next request uses this token as thepageToken
query string value. 您的下一个请求使用此令牌作为pageToken
查询字符串值。
Sample Code Request: 示例代码请求:
GET https://www.googleapis.com/admin/directory/v1/users
?domain=primary domain name&pageToken=token for next results page
&maxResults=max number of results per page
&orderBy=email, givenName, or familyName
&sortOrder=ascending or descending
&query=email, givenName, or familyName:the query's value*
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.