-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetkey.php
More file actions
22 lines (21 loc) · 726 Bytes
/
Copy pathgetkey.php
File metadata and controls
22 lines (21 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$refresh = false;
if (file_exists('oauthkey')) {
$age = time() - filemtime('oauthkey');
if ($age > 20000)
$refresh = true;
} else
$refresh = true;
if ($refresh) {
$oauthKey = file_get_contents('https://www.googleapis.com/oauth2/v1/certs')
or die('Failed to retrieve google public key.');
$keyFile = fopen('oauthkey', 'w') or die ('Failed to open public key file for writing.');
fwrite($keyFile, $oauthKey);
fclose($keyFile);
} else {
$keyFile = fopen('oauthkey', 'r') or die ('Failed to open public key file for reading.');
$oauthKey = fread($keyFile, 5000) or die ('Failed to read from public key file.');
fclose($keyFile);
}
$oauthKey = json_decode($oauthKey, true);
?>