0

Google API를 통해 사용자 계정을 수정 및 삭제하려고합니다. 우리의 목적은 우리 웹 페이지에서 다음 API를 사용하는 것입니다.대량 사용자 이름이 Google API를 통해 수정 및 삭제

사용자 삭제 : 우리가 오류 401 "로그인 필요"우리는 어떻게 구글 API를 통해 삭제 & 이름 바꾸기 사용자에 대한 구글의 API의 URL을 호출하는 지침을 필요 있어 브라우저에서 위의 API URL을 호출하는 동안 https://www.googleapis.com/admin/directory/v1/users/userKey

을 삭제합니다.

또한 아래 URL에 나와있는 단계를 수행했습니다. Api 키 및 OAuth 2.0 클라이언트 ID를 생성합니다. 그 후 내가뿐만 아니라 토큰에 액세스하는 붙어있어

https://developers.google.com/admin-sdk/directory/v1/guides/authorizing

토큰에 액세스하는 사용자의 승인을 필요로한다.

친절 구글 API를 호출하는 단계로 우리를 안내

+0

http://stackoverflow.com/help/mcve – DaImTo

답변

0

참조 : https://developers.google.com/admin-sdk/directory/v1/reference/users/update

당신이 행정적으로이 일을하는 가정, 도메인 넓은 위임 서비스 계정을 사용할 수 있습니다.

https://developers.google.com/api-client-library/php/auth/service-accounts

이 예제는 이름이 기존 사용자에 대한 업데이트 할 수있는 방법을 보여줍니다.

$impersonateUser = '[email protected]'; 

define('SCOPES', implode(' ', array(Google_Service_Directory::ADMIN_DIRECTORY_USER))); 
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . '/path/creds.json'); 

$client = new Google_Client(); 

$client->useApplicationDefaultCredentials(); 
$client->setScopes(SCOPES); 
$client->setSubject($impersonateUser); 

$dir = new Google_Service_Directory($client); 

$gPrimaryEmail = '[email protected]'; 
$firstName  = 'Frank'; 
$lastName  = 'Johnson'; 

$gNameObject = new Google_Service_Directory_UserName(
         array(
         'familyName' => $lastName, 
         'givenName' => $firstName, 
         'fullName' => "$firstName $lastName")); 


$gUserObject = new Google_Service_Directory_User( 
         array( 
         'name' => $gNameObject)); 

$results = $dir->users->update($gPrimaryEmail, $gUserObject); 

print_r($results);