title: How to get user information with Google API PHP SDK
body: <p>I am trying to add a login option to my website for people with Google accounts. I have been able to implement this Facebook but having issues getting user account information with Google.</p>
  
  <p>I am using the Google PHP SDK located here: <a href="https://github.com/google/google-api-php-client" rel="noreferrer">https://github.com/google/google-api-php-client</a></p>
  
  <pre><code>$client = new Google_Client();
  $client-&gt;setClientId($this-&gt;ci-&gt;config-&gt;item('client_id', 'google'));
  $client-&gt;setClientSecret($this-&gt;ci-&gt;config-&gt;item('client_secret', 'google'));
  $client-&gt;setRedirectUri($this-&gt;ci-&gt;config-&gt;item('callback_uri', 'google'));
  $client-&gt;addScope('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login');
  $this-&gt;client-&gt;createAuthUrl();
  </code></pre>
  
  <p>But now how do I access the user's email address and other basic information?</p>
  
  <p>I see in the Google PHP SDK a method called <code>getAccountInfo()</code> in the class <code>Google_Service_IdentityToolkit</code>. However, the parameter it requires is <code>postBody</code> but I am not sure how to get/build that. </p>