24 lines
714 B
PHP
24 lines
714 B
PHP
<?php
|
|
require_once __DIR__ . '/google-config.php';
|
|
|
|
// Hapus sesi sebelumnya jika ada, untuk memastikan login baru
|
|
session_start();
|
|
session_unset();
|
|
|
|
// Parameter untuk otentikasi Google
|
|
$params = [
|
|
'response_type' => 'code',
|
|
'client_id' => GOOGLE_CLIENT_ID,
|
|
'redirect_uri' => GOOGLE_REDIRECT_URI,
|
|
'scope' => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile',
|
|
'access_type' => 'offline',
|
|
'prompt' => 'select_account' // Memaksa pengguna memilih akun setiap kali
|
|
];
|
|
|
|
$auth_url = 'https://accounts.google.com/o/oauth2/v2/auth?' . http_build_query($params);
|
|
|
|
// Redirect ke halaman otentikasi Google
|
|
header('Location: ' . $auth_url);
|
|
exit();
|
|
?>
|