As mentioned the error here:
Error calling GET https://www.googleapis.com/plus/v1/people/me?key=MYKEY: (403) The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions
My code:
$client = new Google_Client();
$client->setApplicationName("maaa");
//$client->setHttpClient($httpClient);
echo "login 2";
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->setRedirectUri($callbackurl);
$client->setDeveloperKey(GOOGLE_API_KEY);
$client->setAccessType("online");
$client->setApprovalPrompt("auto");
$plus = new Google_PlusService($client);
echo "login 3";
if (isset($_GET['code'])) {
echo "login inside....";
try {
$client->authenticate();
} catch(Exception $e) {
echo $e;
}
$token = $client->getAccessToken();
try {
$userProfile = $plus->people->get("me");
} catch(Exception $e) {
//ERROR Error calling GET https://www.googleapis.com/plus/v1/people/me?key=mYKEY: (403) The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions
echo $e;
}
$id = $userProfile['id'];
return array(
'user' => $id,
'network' => 'google',
'userprofile' => $userProfile,
'token' => $token,
'loginUrl' => null,
'logoutUrl' => null
);
} else {
$authUrl = $client->createAuthUrl();
return array(
'user' => 0,
'network' => 'google',
'userprofile' => $userProfile,
'token' => null,
'loginUrl' => $authUrl,
'logoutUrl' => null
);
}
Following is the setting for my api. If I keep the below settings then everything works really well but If I wanted to keep the restriction on HTTP then it won't work. If anyone know to make it work without having any issue with the HTTP option then please let me know.
tHANKS and please let me know if anyone have any idea that how I can send the referer to google client.....