$code, 'client_id' => GOOGLE_CLIENT_ID, 'client_secret' => GOOGLE_CLIENT_SECRET, 'redirect_uri' => GOOGLE_REDIRECT_URI, 'grant_type' => 'authorization_code' ]; $ch = curl_init($token_url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($token_params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code == 200) { $token_data = json_decode($response, true); // For now, just print the token data // In a real application, you would store this securely in a database echo '
';
        print_r($token_data);
        echo '
'; // Store the access token in the session for immediate use $_SESSION['google_access_token'] = $token_data['access_token']; // Redirect back to the dashboard // header('Location: dashboard.php'); // exit(); } else { echo "Error fetching access token: " . $response; } } else { echo "Authorization code not found."; }