0

我们正在建立一种简单的方法来配置新的 G Suite 客户,我们的项目已经能够创建客户和相应的订阅。但用户只能从谷歌收到一些欢迎邮件,并被告知登录。当尝试通过管理目录 api 创建第一个用户时,我们得到的是:

googleapi: Error 403: Access Not Configured. Admin Directory API has not been used in project xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/admin.googleapis.com/overview?project=xxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured"

(敏感信息标有xxx)

API 客户端使用与经销商客户端相同的方法构建,所有这些都是通过我们在(我们的)G Suite 中设置的所需范围的域范围委派服务帐户完成的。

使用转销商控制台跳转到新客户管理界面时,API 已启用(默认)。

在线文档并没有真正说明这一点,只是描述了如何创建用户,但没有列出任何限制。

我们正在使用 Golang 库,用户插入如下所示:

...
usr, err := adm.Users.Insert(trial.User).Do()
if err != nil {
    ...
}

...
err = adm.Users.MakeAdmin(usr.PrimaryEmail, &admin.UserMakeAdmin{
    Status: true,
}).Do()
if err != nil {
    ...
}
...

API客户端是这样构建的:

    const envVar = "GOOGLE_APPLICATION_CREDENTIALS"
    if filename := os.Getenv(envVar); filename != "" {
        serviceAccountJSON, err := ioutil.ReadFile(filename)
        if err != nil {
            log.Fatal("creating oauth client failed", zap.Error(err))
        }
        config, err := google.JWTConfigFromJSON(serviceAccountJSON,
            reseller.AppsOrderScope,
            admin.AdminDirectoryUserScope,
        )

        adminClient = config.Client(ctx)
        config.Subject = *impersonationUser
        resellerClient = config.Client(ctx)
    }
    res, _ := reseller.New(resellerClient)
    adm, _ := admin.New(adminClient)
4

1 回答 1

0

保持问题开放,以防其他人也遇到这种情况。问题是,在我们自己的项目中,Admin SDK API 获得/被禁用。

跳过了设置过程,因此如果您遇到此问题,请尝试启用 Admin SDK API(与 Reseller API 不同)。

于 2018-05-07T15:37:06.093 回答