Support the ongoing development of Laravel.io →
Configuration Requests Validation
Last updated 2 years ago.
0
Solution

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!

Last updated 2 years ago.
0

Thank you!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

sevmardi sevmardi Joined 19 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.