Session_start
session_start();
function generateRandomState() {
return bin2hex(random_bytes(16));
}
if (!isset($_SESSION[‘oauth_state’])) {
$_SESSION[‘oauth_state’] = generateRandomState();
}
$state = $_SESSION[‘oauth_state’];
$authUrl = “https://api.solapi.com/oauth2/v1/authorize?client_id={$clientId}&redirect_uri={$redirectUri}&response_type=code&scope={$scopes}&state={$state}”;
// 인증 URL로 리디렉션
header(‘Location: ‘ . $authUrl);
exit;
?>