📄 Source: oauth2callback.php
<?php
session_start();
require_once 'vendor/autoload.php';
$baseUrl = "https://createcraftweb.playit.plus/AgentAI";
$client = new Google\Client();
$client->setClientId('1082083393389-c5uekspcp2boc1gd0n0gr3v1a5vbb3jg.apps.googleusercontent.com');
$client->setClientSecret('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'); // ← PASTE YOUR CLIENT SECRET HERE
$client->setRedirectUri("$baseUrl/oauth2callback.php");
if (isset($_GET['code'])) {
try {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
if (!isset($token['error'])) {
$_SESSION['access_token'] = $token;
file_put_contents(__DIR__ . '/tmp/token.json', json_encode($token));
header('Location: index.php');
exit();
} else {
throw new Exception($token['error_description'] ?? 'Unknown error');
}
} catch (Exception $e) {
echo "Authentication failed: " . $e->getMessage();
echo "<br><a href='index.php'>Try again</a>";
}
} else {
echo "No authorization code received.";
echo "<br><a href='index.php'>Go back</a>";
}
?>
← Back