私は得ています
Error calling GET https://www.googleapis.com/admin/directory/v1/users/email@example.com.com: (403) Not Authorized to access this resource/api
実行中
$client = new Google_Client();
$client->setClientId(GOOGLEAPPS_CLIENT_ID);
$client->setApplicationName(SITE_NAME);
$key = file_get_contents(APPLICATION_PATH . 'googleapps-privatekey.p12');
$assertion = new Google_AssertionCredentials(
GOOGLEAPPS_EMAIL_ADDRESS, // the service account name
array('https://www.googleapis.com/auth/admin.directory.user'), // see https://developers.google.com/admin-sdk/directory/v1/guides/authorizing
$key);
$client->setAssertionCredentials($assertion);
$service = new Google_DirectoryService($client);
$user = $service->users->get('email@example.com');
https://developers.google.com/admin-sdk/directory/v1/guides/prerequisitesの指示に従い、[ API アクセスを有効にする] にチェックを入れました。Google API コンソールhttps://code.google.com/apis/consoleを使用してサービス アカウント キーを生成したところ、問題なく動作しました。
https://groups.google.com/forum/#!msg/google-api-php-client/LM-mwmuZe7I/IA_K5v1R1UMJ
Google PHP ライブラリを使用し、 https://code.google.com/p/google-api-php-client/wiki/OAuth2?hl=no#Service_Accountsの指示に従ってサービス アカウントを機能させてみました。彼らのコードへのデバッグ: 私は正常に承認し、期待どおりに新しいアクセス トークンを取得しています https://developers.google.com/accounts/docs/OAuth2ServiceAccount。
読んだすべての内容で、すべてをオンに切り替えたと表示されているのに、「このリソース/API にアクセスする権限がありません」というメッセージが表示される理由がわかりません。何か案は?