使用Google Admin SDK Directory API时,"域名无法使用apis"

use*_*997 14 google-admin-sdk

我正在尝试使用Admin SDK Directory API,专门用于检索Users:get端点详细说明的用户信息.

我在oauthing时请求了以下权限

https://www.googleapis.com/auth/admin.directory.user
https://www.googleapis.com/auth/admin.directory.user.readonly
Run Code Online (Sandbox Code Playgroud)

但是,当我发出获取特定用户信息的请求时,我得到以下响应:

HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 26 Jul 2013 18:25:29 GMT
Expires: Fri, 26 Jul 2013 18:25:29 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "domainCannotUseApis",
    "message": "Domain cannot use apis."
   }
  ],
  "code": 403,
  "message": "Domain cannot use apis."
 }
}
Run Code Online (Sandbox Code Playgroud)

我在API控制台中启用了Admin SDK .

我在Google Apps标准版(免费版)和Google Apps for Nonprofits版上试过了这个版本并得到了同样的错误.Admin SDK Directory API是否需要Google Apps for Business帐户?

Jay*_*Lee 24

您需要在G Suite控制面板中启用管理API.