I'm trying to create events in my google calendar with the google quickadd API. Here is my code:
require_once 'googleapi/vendor/autoload.php';
$client = new Google\Client();
$client->setApplicationName("Google Calendar API");
$client->setDeveloperKey("AIzaSyDdR3w2J59ZVVv_s7BopzNuteu1Bzo");
$client->setAuthConfig('googleapi/code_secret_client_62725432848-um1gbjoo7iqi1upvmv4niosddfte43.apps.googleusercontent.com.json');
$client->addScope("https://www.googleapis.com/auth/calendar.events");
$service = new Google_Service_Calendar($client);
// echo "<pre>";
// print_r($service);
// echo "</pre>";
$createdEvent = $service->events->quickAdd(
'[email protected]',
'Appointment at Somewhere on June 3rd 10am-10:25am'
);
echo $createdEvent->getId();
I keep getting the error below. Can someone please tell me why?
Fatal error: Uncaught Google\Service\Exception: { "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Login Required.", "domain": "global", "reason": "required", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED" } } in C:\xampp\htdocs\google quick add\googleapi\src\Http\REST.php:128 Stack trace: #0 C:\xampp\htdocs\google quick add\googleapi\src\Http\REST.php(103): Google\Http\REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal function]: Google\Http\REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 C:\xampp\htdocs\google quick add\googleapi\src\Task\Runner.php(18 in C:\xampp\htdocs\google quick add\googleapi\src\Http\REST.php on line 128