【问题标题】:How to I get a list of user accounts with the google directory API?如何使用 google 目录 API 获取用户帐户列表?
【发布时间】:2015-08-23 09:11:22
【问题描述】:

这是我的代码:

String key = Console.ReadLine();    //input oauth2.0 key from google
Console.WriteLine(key);
        Google.Apis.Admin.Directory.directory_v1.DirectoryService service = new Google.Apis.Admin.Directory.directory_v1.DirectoryService(new BaseClientService.Initializer
        {

        ApplicationName = "MY APPLICATION",
        ApiKey = key,


        });
Google.Apis.Admin.Directory.directory_v1.UsersResource.GetRequest u = service.Users.Get("test@example.net");
        Console.WriteLine(u.UserKey);


        Google.Apis.Admin.Directory.directory_v1.Data.User response = await u.ExecuteAsync();
Console.WriteLine(response);

即使我有一个来自 Google 的 OAuth2.0 密钥“密钥”,我也会收到一条错误消息,回复内容类似于错误:需要登录。我应该如何更改代码,以便获取(并最终设置)用户信息而不会出现此类错误?

编辑:我的授权密钥范围是全局用户范围。

【问题讨论】:

标签: c# google-admin-sdk google-directory-api


【解决方案1】:

我假设您正在使用 Java 上的 Directory API。点击这个链接,https://developers.google.com/admin-sdk/directory/v1/quickstart/java,它是 Google 的 Directory API 的文档,他们给出了列出用户的例子。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    相关资源
    最近更新 更多