Service Accounts

Service Accounts

As of Google Apps Login version 2.5, users can configure a Service Account which your extensions can access. The Google Apps Directory plugin is a free example plugin that takes advantage of this.

See gal_gather_serviceacct_reqs below. And here is some example code as to how you might obtain the Service Account object:

if (!function_exists('GoogleAppsLogin')) {
   die("Google Apps Login plugin needs to be activated and configured");
try {
   $gal = GoogleAppsLogin();

   $cred = $gal->get_Auth_AssertionCredentials(
   $serviceclient = $gal->get_Google_Client();
   // Include paths were set when client was created
   if (!class_exists('GoogleGAL_Service_Directory')) {
      require_once( 'Google/Service/Directory.php' );
   $userservice = new GoogleGAL_Service_Directory($serviceclient);
   $usersresult = $userservice->users->listUsers(Array('query' => $searchstr, 'customer' => 'my_customer'));
   $usersdata = $usersresult->getUsers();

Filter: gal_gather_serviceacct_reqs

The Login plugin applies this filter to allow your extension to instruct it to list extra Google domain-wide authorization scopes (permissions) when providing instructions for the user to configure the Service Account.


$reqs_array – Array of scope definitions from other plugins.


Array of scope definitions, adding your own scope definitions first if needed. Do not worry about potential duplicates – the plugin takes care of that.

The array element you should add is an array itself containing:
Your extension name in element 0, and another array in element 1.
That other array (in element 1) should be an associative array of Google API scopes mapping to plain English reasons why your extension needs that scope.

This information only adds to the documentation instructing a user to set up the Service Account. The scopes aren’t added automatically just because they are listed in response to this filter.


public function gad_gather_serviceacct_reqs($reqs_array) {
   $reqs_array[] = array('Google Apps Directory', 
                       => 'Search for user information in your domain'));
   return $reqs_array;

add_filter('gal_gather_serviceacct_reqs', 'gad_gather_serviceacct_reqs' );
Google Apps Login is trusted by thousands of organizations from small businesses to NASDAQ-listed companies and government organizations.

Users click their way through Login via Google (just one click after the first time)

Users click their way through Login via Google (just one click after the first time)

You can try it out by clicking below to auto-create a test account on this site! This will show you the basic Google login process.
Try out Google login

Logging in is only the start – Google Apps Login takes care of all your WordPress user management. Find out more here.