Not sure if I understand your question correctly.
You could actually avoid doing google auth all the time by setting access_type
to offline
in your Google API configuration. If I remember correctly, you have to enable it in Google console as well.
In that case you only need to do once, and you can save the access token it returns to your config file.
It's been awhile since I wrote it as a service provider, so hopefully I remember them correctly. Example code,
try {
$google = new Google_Client($config); // remember to change $config['access_type'] = 'offline';
$accessToken = Config::get('google.access_token'); // access token you saved earlier
$google->setAccessToken($accessToken);
$cal = new Google_CalendarService($google);
// Now you get do whatever you want in $cal
// Please refer to this for more information
// vendor /bitgandtter / google-api / src / contrib / Google_CalendarService.php
// For example, you want to grab the list of calendars that person has.
// @return Google_CalendarList
$calendarList = $cal->calendarList->listCalendarList();
catch (Google_ServiceException $e) {
// Your action ...
}
catch (Google_AuthException $e) {
// Your action ...
}
Hope it helps!
Cheers!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community