google-API-Client从google管理员sdk返回空响应

时间:2018-07-17 09:24:50

标签: javascript api google-api-client google-admin-sdk

我正在尝试从google admin sdk中提取用户。我进行了以下设置:

功能

public function getGoogleUsers ()
    {

        putenv('GOOGLE_APPLICATION_CREDENTIALS=' . resource_path('assets/keys/X-X-X-X-X-X-X'));
        $client = new \Google_Client();
        $client->useApplicationDefaultCredentials();
        $client->setApplicationName('X-X-X-X-X');
        $client->setScopes(array(
            'https://www.googleapis.com/auth/admin.directory.group.member.readonly',
            'https://www.googleapis.com/auth/admin.directory.group.member.readonly',
            'https://www.googleapis.com/auth/admin.directory.orgunit.readonly',
            'https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly',
            'https://www.googleapis.com/auth/admin.directory.user.alias.readonly',
            'https://www.googleapis.com/auth/admin.directory.user.readonly',
            'https://www.googleapis.com/auth/admin.directory.userschema.readonly'
        ));
        $client->setAccessType('offline');

        $client->setSubject('X-X-X-X-X');

        $response = new \Google_Service_Directory($client);

        return json_encode($response);
    }

我已设置 OAuth 2.0客户端ID ,已启用域范围授权,已启用 admin sdk api ,添加了上述范围的权限。但是由于某种原因,我一直收到空洞的答复。

empty response

0 个答案:

没有答案