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.
I am using the Google PHP SDK located here: https://github.com/google/google-api-php-client
$client = new Google_Client();
$client->setClientId($this->ci->config->item('client_id', 'google'));
$client->setClientSecret($this->ci->config->item('client_secret', 'google'));
$client->setRedirectUri($this->ci->config->item('callback_uri', 'google'));
$client->addScope('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login');
$this->client->createAuthUrl();
But now how do I access the user's email address and other basic information?
I see in the Google PHP SDK a method called getAccountInfo()
in the class Google_Service_IdentityToolkit
. However, the parameter it requires is postBody
but I am not sure how to get/build that.