2013-12-18 3 views
0

이전 프로비저닝 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) );

답변

1

이동 https://cloud.google.com/console
에 프로젝트에
클릭 'API와 인증'
선택 '서비스 계정'
클릭 '새 클라이언트 ID 만들기'에 '자격 증명'
클릭에
클릭 선택 '만들기 클라이언트 ID '
개인 키가 다운로드됩니다.
공개 키가 저장되어 콘솔에 표시됩니다.
개인 키를 다시 검색 할 수 없습니다. Google은 한 번만 보냅니다. 분실 한 경우 다시 처리해야하며 응용 프로그램에서 관련 설정을 업데이트해야합니다.
이 질문에 대한 답변이 제공된 경우이를 표시하십시오.

관련 문제