[insert_php]
session_start();
$client = new Google_Client();
$client->setAuthConfigFile(‘wp-content/client_secret.json’);
$client->setRedirectUri(‘http://professionalmaids.co.uk/oauth2callback’);
$client->addScope(Google_Service_Calendar::CALENDAR_READONLY);
if (! isset($_GET[‘code’])) {
$auth_url = $client->createAuthUrl();
header(‘Location: ‘ . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
$client->authenticate($_GET[‘code’]);
$_SESSION[‘access_token’] = $client->getAccessToken();
$redirect_uri = ‘http://professionalmaids.co.uk/’;
header(‘Location: ‘ . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
[/insert_php]