列出在Java中使用Google Admin SDK的用户 [英] Listing users using Google Admin SDK in Java

查看:52
本文介绍了列出在Java中使用Google Admin SDK的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出google中定义的域中的用户.我看到它可以通过Google Admin Directory SDK获得. 虽然,我找不到任何示例或文档,但如何在Java中使用它. 我已经有了授权部分.我只是不确定应该从API中使用哪些对象,以及如何使用.

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.

谢谢!

推荐答案

以下是相关导入的示例

从文档中( https://developers.google. com/admin-sdk/directory/v1/reference/users/list )

作为帐户管理员,您还可以使用my_customer别名来 代表您帐户的customerId

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();
    }

这篇关于列出在Java中使用Google Admin SDK的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆