-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
47 lines (36 loc) · 1.6 KB
/
config.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once 'vendor/autoload.php';
$client = new Google_Client();
$google_client_id = '290880609641-uiokj73etdah9h0fllkatjf4j8gii0hn.apps.googleusercontent.com';
$google_client_secret = 'lVEeEPJ3pdpCVAFciq1ZZGvH';
$google_redirect_uri = 'http://localhost:8080';
$api_key = 'AIzaSyBCUkzA23H9RF1LAGgRsFxWm-a6fJ2L0TI';
$azure_client_id = 'cfb7c62b-f1c8-4b0e-a2bf-1de311de74dd';
$azure_client_secret = '66ca97a5-98f4-441b-9873-de38b6ac9a6f';
$azure_redirect_uri = 'http://localhost:8080';
$client->setClientId($google_client_id);
$client->setClientSecret($google_client_secret);
$client->setRedirectUri($google_redirect_uri);
$client->setDeveloperKey($api_key);
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->addScope("email");
$client->addScope("profile");
session_start();
// Remove cors error in php server
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
$headers = getallheaders();
if (isset($headers['Authorization'])) {
$token = str_replace('Bearer ', '', $headers['Authorization']);
$client->setAccessToken($token);
}