-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback.php
More file actions
40 lines (30 loc) · 1.21 KB
/
callback.php
File metadata and controls
40 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once 'config.php';
if (isset($_GET['error'])) {
die("Kick Yetkilendirme Hatası: " . htmlspecialchars($_GET['error_description'] ?? $_GET['error']));
}
if (!isset($_GET['code']) || !isset($_GET['state'])) {
die("Gerekli yetkilendirme parametreleri eksik.");
}
if ($_GET['state'] !== $_SESSION['oauth2state']) {
unset($_SESSION['oauth2state']);
die("Geçersiz State (CSRF Koruması). Lütfen tekrar giriş yapmayı deneyin.");
}
if (!isset($_SESSION['pkce_verifier'])) {
die("PKCE Verifier oturumda bulunamadı. Lütfen tekrar giriş yapmayı deneyin.");
}
$tokenData = exchangeCodeForToken($_GET['code'], $_SESSION['pkce_verifier']);
unset($_SESSION['oauth2state']);
unset($_SESSION['pkce_verifier']);
if ($tokenData && isset($tokenData['access_token'])) {
$_SESSION['kick_access_token'] = $tokenData['access_token'];
if (isset($tokenData['refresh_token'])) {
$_SESSION['kick_refresh_token'] = $tokenData['refresh_token'];
}
saveAccessToken($tokenData['access_token'], $tokenData['refresh_token'] ?? null);
header('Location: /index.php');
exit;
} else {
die("Token alınamadı. Lütfen ayarlarınızı ve config dosyanızı kontrol edin.");
}
?>