이전 프로비저닝 API에서 새 Admin SDK로 마이그레이션해야합니다. 문제는 OAuth2를 서비스 계정으로 작업하는 방법을 파악할 수 없다는 것입니다. 우리는 다음 코드를 예제로 사용하지만 key.p12 파일이 생성 된 위치와 방법을 파악할 수 없습니다. 나는 서비스 계정을 cliendId, 전자 메일 주소 및 API 키를 사용하여 개발자 콘솔에서 응용 프로그램으로 내 서버에 묶어 만들었습니다. 누군가가 key.p12 파일을 만드는 방법을 이해하는 데 도움을 줄 수 있다면이 작업을 수행 할 수 있다고 확신합니다.서비스 계정으로 OAuth2를 사용하는 방법
감사합니다,
스키
// Set your client id, service account name, and the path to your private key.
// For more information about obtaining these keys, visit:
// https://developers.google.com/console/help/#service_accounts
const CLIENT_ID = 'insert_your_client_id';
const SERVICE_ACCOUNT_NAME = 'insert_your_service_account_name';
// Make sure you keep your key.p12 file in a secure location, and isn't
// readable by others.
const KEY_FILE = '/super/secret/path/to/key.p12';
// Load the key in PKCS 12 format (you need to download this from the
// Google API Console when the service account was created.
$client = new Google_Client();
... $ 키 =의 file_get_contents (KEY_FILE); $ client-> setClientId (CLIENT_ID); $ client-> setAssertionCredentials (새 Google_AssertionCredentials ( SERVICE_ACCOUNT_NAME, 배열 ('https://www.googleapis.com/auth/prediction'), $ key) );