不允许通过转销商API将第一个用户添加到新配置的客户

时间:2018-05-07 15:26:45

标签: go google-admin-sdk google-directory-api google-reseller-api

我们正在设置一种简单的方法来配置新的G Suite客户,我们的项目已经能够创建客户和相应的订阅。 但是,用户只能从Google收到一些欢迎邮件,并被告知要登录。 当试图通过管理目录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)

1 个答案:

答案 0 :(得分:0)

保持问题公开以防万一其他人偶然发现这个问题。 问题是,在我们自己的项目中,Admin SDK API已被禁用。

完成设置过程,如果遇到此问题,请尝试启用Admin SDK API(与转销商API不同)。