there i found some error, when i want to make sure the session on Login with google account. And the error is :
Fatal error: Uncaught InvalidArgumentException: Invalid token format in C:\xampp\htdocs\google\googleAPI\src\Google\Client.php:434 Stack trace: #0 C:\xampp\htdocs\google\callback.php(5): Google_Client->setAccessToken(Array) #1 {main} thrown in C:\xampp\htdocs\google\googleAPI\src\Google\Client.php on line 434
and then this is my code :
<?php
require_once('config.php');
if (isset($_SESSION['accessToken'])){
$client->setAccessToken($_SESSION['accessToken']);
}
else if (isset($_GET['code'])) {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
$_SESSION['accessToken'] = $token;
}
else{
header("location: index.php");
}
$oAtuth = new Google_Service_Oauth2($client);
$user = $oAtuth->userinfo->get();
echo "<pre>";
print_r($user);
?>
Please tell me whats wrong with this code
You have wrong value of token in $_SESSION['accessToken']
.