APD Toronto
asked on
Google Service Exception
Hi Experts,
I am trying to use the Google Calendar API with the Following code
But I getting the following error:
My first thoughts was to go under my Google API console and under Domain Verification Add a domain. This referred me to Webmaster Central, but I cannot add my localhost. Do I need to use a real domain only, and can I use a subdomain? However, maybe I am completely on the wrong track?
Any help will be appreciated.
I am trying to use the Google Calendar API with the Following code
<?php
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setAuthConfig(__DIR__ . '/client_secret.json');
$calendar = new Google_Service_Calendar($client);
$events = $calendar->events->listEvents('apdcompany.test@gmail.com');
print_variable($events, 'Google Calendar Events');
function print_variable($var, $label, $raw = true){
echo '<br>=========START=========<br>';
echo '<b>' . $label . '</b>';
if ($raw == true) echo '<pre>';
print_r($var);
if ($raw == true) echo '</pre>';
echo '<br>=========END=========<br>';
}
?>
But I getting the following error:
PHP Fatal error: Uncaught Google_Service_Exception: {
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
in C:\inetpub\wwwroot\test\gmail_calendar\vendor\google\apiclient\src\Google\Http\REST.php:118
Stack trace:
#0 C:\inetpub\wwwroot\test\gmail_calendar\vendor\google\apiclient\src\Google\Http\REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#1 C:\inetpub\wwwroot\test\gmail_calendar\vendor\google\apiclient\src\Google\Task\Runner.php(181): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#2 C:\inetpub\wwwroot\test\gmail_calendar\vendor\google\apiclient\src\ in C:\inetpub\wwwroot\test\gmail_calendar\vendor\google\apiclient\src\Google\Http\REST.php on line 118
My first thoughts was to go under my Google API console and under Domain Verification Add a domain. This referred me to Webmaster Central, but I cannot add my localhost. Do I need to use a real domain only, and can I use a subdomain? However, maybe I am completely on the wrong track?
Any help will be appreciated.
You just need to go through the signup process + use a valid license key for access + then stay within your access limits.
The message above is clear...
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
Your App is exceeding the daily usage limit for anonymous version. You have to signup for the number of calls you're making to work correctly.
The message above is clear...
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
Your App is exceeding the daily usage limit for anonymous version. You have to signup for the number of calls you're making to work correctly.
ASKER
The quota is 1M/dday, today I made zero.
Also, why is it saying
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
.When on line 6 I (think) am using the .json file that I downloaded from the console?
Also, why is it saying
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
.When on line 6 I (think) am using the .json file that I downloaded from the console?
ASKER
How do I
As stated I am using the provided .json file.
You just need to go through the signup process + use a valid license key for access + then stay within your access limits.
As stated I am using the provided .json file.
The 1M quota is for authenticated users, +1M for authenticated paid users, unauthenticated users have no access (quota of zero) to Google APIs (including Calander).
Prerequisites
To run this quickstart, you'll need:
PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed.
The Composer dependency management tool.
Access to the internet and a web browser.
A Google account with Google Calendar enabled.
https://developers.google.com/google-apps/calendar/quickstart/php
Prerequisites
To run this quickstart, you'll need:
PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed.
The Composer dependency management tool.
Access to the internet and a web browser.
A Google account with Google Calendar enabled.
https://developers.google.com/google-apps/calendar/quickstart/php
Nowhere in your code are you actually handling any authentication. The client_secret.json file simply specifies the details of your App, along with the callback used AFTER a user has authenticated themselves.
The Google API uses oAuth for it's authentication, and you have a couple of options here, depending on what you want your app to do.
If you want your app (webpage) to show your own Events, then you would need to Authenticate with a Service Account. If you want your app to show your user's Events when they visit your page, then you would need to Authenticate with a Client ID (and a callback script).
Let us know exactly what you're trying to do and we'll be able to point you in the right direction.
The Google API uses oAuth for it's authentication, and you have a couple of options here, depending on what you want your app to do.
If you want your app (webpage) to show your own Events, then you would need to Authenticate with a Service Account. If you want your app to show your user's Events when they visit your page, then you would need to Authenticate with a Client ID (and a callback script).
Let us know exactly what you're trying to do and we'll be able to point you in the right direction.
ASKER
This is a web-based app for internal use by staff. The Google Calendar portion will be for staff to schedule future appointments.
So, in this, its working with my own calendar events.
So, in this, its working with my own calendar events.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You!!!
Check your Google Dashboard:
https://console.developers.google.com/apis/dashboard
If you already have the account setup for Calander API, you might need a paid license:
https://developers.google.com/google-apps/calendar/terms
So that must mean the API key exceeded the 1M access limit
https://developers.google.com/google-apps/calendar/pricing
https://cloud.google.com/billing/docs/how-to/manage-billing-account?visit_id=1-636473423418306838-397247662&rd=1