title: Google Groups Directory API - Add user to group raises error - PHP
body: <p>I have been trying to add members to my google apps group. I am trying with following code but it raises error. Don't know what is doing wrong.</p>
  
  <pre><code>include_once 'api-client/autoload.php';
  
  $clientId = 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
  
  $serviceAccountName = 'xxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com';
  
  $delegatedAdmin = 'superadmin@domain.com';
  
  $keyFile = 'mw-gxxxxxxxx.p12';
  
  $appName = 'Example App';
  
  $scopes = array(
      'https://www.googleapis.com/auth/admin.directory.group'
  );
  
  $creds = new Google_Auth_AssertionCredentials(
      $serviceAccountName,
      $scopes,
      file_get_contents($keyFile)
  );
  
  $creds-&gt;sub = $delegatedAdmin;
  
  $client = new Google_Client();
  $client-&gt;setApplicationName($appName);
  $client-&gt;setClientId($clientId);
  $client-&gt;setAssertionCredentials($creds);
  
  $dir = new Google_Service_Directory($client);
  
  
   $member = new Google_Service_Directory_Member(array('name@domain.com',
                          'kind' =&gt; 'admin#directory#member',
                          'role' =&gt; 'MEMBER',
                          'type' =&gt; 'USER'));
  
  $list = $dir-&gt;members-&gt;insert('01tuee7433xxxxx', $member);
  </code></pre>
  
  <h1><strong>The error:</strong></h1>
  
  <pre><code>Fatal error: Uncaught exception 'Google_Service_Exception' with message 
  'Error calling POST https://www.googleapis.com/admin/directory/v1/groups/01tuee7433v8xwz/members: (400) Missing required field: memberKey'
  </code></pre>