| 12345678910111213141516171819202122232425262728 |
- <?php
- require __DIR__ . '/vendor/autoload.php';
- use Google\Client;
- $client = new Client();
- $client->setAuthConfig('/var/www/secure/oauth-client.json');
- $client->setRedirectUri('https://llm.modulos.com.au/oauth_callback.php');
- $client->setScopes([
- Google\Service\Drive::DRIVE,
- Google\Service\Docs::DOCUMENTS
- ]);
- if (!isset($_GET['code'])) {
- http_response_code(400);
- echo 'Missing ?code';
- exit;
- }
- $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
- if (isset($token['error'])) {
- http_response_code(500);
- echo 'OAuth error: ' . htmlspecialchars(json_encode($token));
- exit;
- }
- file_put_contents(__DIR__ . '/cache/gdocs_token.json', json_encode($token, JSON_PRETTY_PRINT));
- echo '<h3>Connected ✅</h3><p>You can close this tab and try “Create Google Doc” again.</p>';
|