BlueGit

projects-timfalken-com verhalenboek

Files

verhalenboek / web / auth.php

auth.php

feat: voeg Verhalenboek toe met dagen, leesvoortgang en schrijf-API
timfa project_87242033_bot_b167a9be22027ad5a4b431d0ad8426c6 · pushed by timfa · 6 weeks ago
799da657 History
auth.php 782 B Download Raw
1<?php
2declare(strict_types=1);
3require __DIR__.'/lib/bootstrap.php';
4try {
5 $cfg = config();
6 if (($cfg['client_id'] ?? '') === '' || ($cfg['client_secret'] ?? '') === '') {
7 throw new RuntimeException('Productie-login heeft een geregistreerde client-id en een geheim nodig. Zie README.md.');
8 }
9 $_SESSION['oauth_state'] = bin2hex(random_bytes(32));
10 $_SESSION['oauth_started'] = time();
11 header('Location: https://auth.timfalken.com/oauth/authorize?'.http_build_query([
12 'client_id' => $cfg['client_id'],
13 'redirect_uri' => baseUrl().'/callback.php',
14 'response_type' => 'code',
15 'state' => $_SESSION['oauth_state'],
16 ]));
17} catch (Throwable $e) {
18 http_response_code(503);
19 echo htmlspecialchars($e->getMessage());
20}