Google API 콘솔에 APP가 있습니다. Admin SDK와 Marketplace SDK가 활성화되어 있습니다. 서비스 계정으로 등록하고 키 파일 등을 가지고 있습니다. 특정 도메인에서 사용자를 얻으려고하면 항상 하나의 메시지가 표시됩니다. "GET https://www.googleapis.com/admin/directory/v1/users?domain=mydomain.com을 호출하는 중 오류가 발생했습니다 : (403)이 액세스 권한이 없습니다. 리소스/api ". 내가 가지고있는 코드는 다음과 같습니다.Google API - 서비스 디렉토리 사용
$client = new Google_Client();
$client->setApplicationName("Client_User_Feed");
$key = file_get_contents('/path/to/key/key-file-privatekey.p12');
$cred = new Google_Auth_AssertionCredentials(
'{code}@developer.gserviceaccount.com',
array('https://www.googleapis.com/auth/admin.directory.user'),
$key
);
$client->setAssertionCredentials($cred);
$service = new Google_Service_Directory($client);
$users = $service->users->listUsers(array('domain' => 'mydomain.com'));
이 문제를 어떻게 해결할 수 있습니까?
$adminUser = '[email protected]'; $cred->sub = $adminUser;
예제 코드 가져 오는 사용자 ID :
이 도메인의 관리 콘솔에서 응용 프로그램의 범위를 추가 했습니까? – radia
Marketplace SDK admin - ttps : //www.googleapis.com/auth/admin.directory.user – Deez