简体   繁体   English

如何从我的域中提取500多个用户对象?

[英]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 the nextPageToken property which gives a token for the next page of response results. 在分页的情况下,响应返回nextPageToken属性,该属性为响应结果的下一页提供令牌。 Your next request uses this token as the pageToken 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.

相关问题 如何将DBUtils结果集转换为由更多域对象组成的JavaBeans? - How to transform DBUtils resultset into JavaBeans composited from more domain objects? 如何从Java方法向Servlet返回两个以上的对象 - How to return more than two objects from java method to a servlet 如何在Web应用程序中锁定消息以防止多个用户对其进行编辑 - How to lock a mesage in a webapp to prevent more than 1 user from editing it 如何限制用户在控制台中输入三个以上的整数? - How to limit the user from typing in more than three integers into the console? 程序不会从数据库中提取多行 - Program wont pull more rows than one from database 如何在Google Directory API中获取超过500个用户的列表? - How to fetch a list of more than 500 users in Google Directory API? 如何阻止我的代码多次打印“升序”? - How to stop my code from printing "Ascending" more than once? 如何将 map 从具有对象列表的 Model 实体和一个 Object 到具有 Mapstruct 的单个域实体 - How to map from Model entity with list of Objects and one more Object to single Domain entity with Mapstruct 从用户读取多个单词 - reading more than one word from user 如何应对用户多次点击 - How to react to user tapping more than once
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM