On occasion, you want to build an application to interact with G Suite without logging to the console. The G Suite Admin SDK is a tool for the purpose.
In authentication, there are two ways to do it.
The first option is great for automate tasks, such as generating reports, but not recommended for web app with access from anyone.
Let’s look at how to implement option #2 with Laravel.
composer require google/apiclient:2.0
client_secretthe same way you when setting up Socialite using Google OAuth.
6. Back to using Google client, create a
$client as below
$client = new Google_Client();
$client->setApplicationName('G Suite Directory Demo');
$client->setAccessToken([User Token here]);
$service = new Google_Service_Group($client);
$optParams = array(
'userKey' => 'email@example.com',
'maxResult' => 10
$results = $service->groups->listGroups($optParams);