-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.php
32 lines (21 loc) · 822 Bytes
/
index.php
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
<?php
// Copy your client id and secret from Google developer console
$clientId = '';
$clientSecret = '';
$redirectUrl = 'http://localhost';
// -----------------------------------------------------------------------------
// DO NOT EDIT BELOW THIS LINE
// -----------------------------------------------------------------------------
require_once 'src/Google_Client.php';
session_start();
$client = new Google_Client();
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->setRedirectUri($redirectUrl);
$client->setScopes(array('https://spreadsheets.google.com/feeds'));
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
print_r(json_decode($client->getAccessToken(), true));
exit;
}
print '<a href="' . $client->createAuthUrl() . '">Authenticate</a>';