私はユーザーの連絡先を取得できるGoogle People APIを使用しようとしています。ここに私のコードです:Google People APIがスコープについてエラーを投げています
$scriptUri = "http://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];
$client = new Google_Client();
$client->setClientId('OMITTED');
$client->setClientSecret('OMITTED');
$client->setRedirectUri($scriptUri);
//$client->setAccessType('offline');
$client->setScopes(array('https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/contacts.readonly', 'profile'));
if (isset($_GET['oauth'])) {
// Start auth flow by redirecting to Google's auth server
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else if (isset($_GET['code'])) {
// Receive auth code from Google, exchange it for an access token, and
// redirect to your base URL
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
} else if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
// You have an access token; use it to call the People API
$client->setAccessToken($_SESSION['access_token']);
$people_service = new Google_Service_People($client);
$connections = $people_service->people->get('people/me');
// TODO: Use service object to request People data
} else {
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/?oauth';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
$接続ラインが呼び出されると、次のエラーがスローされます。
はがキャッチされない例外メッセージで「Google_Service_Exception」「https://people.googleapis.com/v1/people/me GET呼び出しエラー:(403)、発信者が行います「人/私」を要求する許可はありません。リクエストには、次のスコープのいずれかが必要です。[profile、https://www.googleapis.com/auth/plus.login]。
上記のスコープが設定されているため、エラーが発生している理由がわかりません。
すべてのご協力ありがとうございます。