Hi,
Google+ API (which will be shut down) seems to be only used to get user datas.
The solution could be to use People API in place of Google+ API in hybridauth/Hybrid/Providers/Google.php
I did the following modifications and it seems to be working.
As I only need to get email, first name, last name and display name, it seems sufficient.
Line 19 :
public $scope = "profile https://www.googleapis.com/auth/plus.profile.emails.read";
becomes :
public $scope = "profile email";
Line 29 :
$this->api->api_base_url = "https://www.googleapis.com/plus/v1/";
becomes :
$this->api->api_base_url = "https://www.googleapis.com/oauth2/v1/";
Line 73 to 101 :
$response = $this->api->api( "https://www.googleapis.com/plus/v1/people/me" );
...
}
becomes :
$response = $this->api->api( "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses" );
if ( ! isset( $response->resourceName) || isset( $response->error ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
$this->user->profile->identifier = (property_exists($response,'resourceName'))?$response->resourceName:((property_exists($response,'resourceName'))?$response->resourceName:"");
$this->user->profile->firstName = "";
$this->user->profile->lastName = "";
$this->user->profile->displayName = "";
if (property_exists($response, 'names')) {
if (is_array($response->names) && count($response->names) > 0) {
$this->user->profile->firstName = isset($response->names[0]->givenName)?$response->names[0]->givenName:"";
$this->user->profile->lastName = isset($response->names[0]->familyName)?$response->names[0]->familyName:"";
$this->user->profile->displayName = isset($response->names[0]->displayName)?$response->names[0]->displayName:"";
}
}
$this->user->profile->email = "";
if (property_exists($response, 'emailAddresses')) {
if (is_array($response->emailAddresses) && count($response->emailAddresses) > 0) {
$this->user->profile->email = isset($response->emailAddresses[0]->value)?$response->emailAddresses[0]->value:"";
}
}
$this->user->profile->photoURL = (property_exists($response,'image'))?((property_exists($response->image,'url'))?substr($response->image->url, 0, -2)."200":''):'';
$this->user->profile->profileURL = (property_exists($response,'url'))?$response->url:"";
$this->user->profile->description = (property_exists($response,'aboutMe'))?$response->aboutMe:"";
$this->user->profile->gender = (property_exists($response,'gender'))?$response->gender:"";
$this->user->profile->language = (property_exists($response,'locale'))?$response->locale:'';
And last important thing, to migrate old identifiers, I need to update existing entries in the database (change WPCUSTOMPREFIX to match your database) :
update WPCUSTOMPREFIX_wslusersprofiles set identifier = concat('people/',identifier) where provider = 'Google' and identifier not like 'people/%';
I knows it’s not the most elegant PHP code possible… but it seems to work.
As I am not sure that it doesn’t break something elsewhere, I suggest you to try in a dev environment…
Such modifications would be overriden if the plugin should be updated but it seems that it is no longer maintained.