HybirdAuth user profile request error

I am using HybridAuth2 with CakePHP and my controller function is

public function loginwith($provider) { // $this->autoRender = false; require_once( WWW_ROOT . 'hybridauth/Hybrid/Auth.php' ); $hybridauth_config = array( "base_url" => 'http://' . $_SERVER['HTTP_HOST'] . $this->base . "/hybridauth/", // set hybridauth path "providers" => array( "Google" => array( "enabled" => true, "keys" => array("id" => "clientID", "secret" => "clientSecret") ) ) ); try { // create an instance for Hybridauth with the configuration file path as parameter $hybridauth = new Hybrid_Auth($hybridauth_config); // try to authenticate the selected $provider $adapter = $hybridauth->authenticate($provider); // grab the user profile $user_profile = $adapter->getUserProfile(); debug($user_profile); } catch (Exception $e) { // Display the recived error switch ($e->getCode()) { case 0 : $error = "Unspecified error."; break; case 1 : $error = "Hybriauth configuration error."; break; case 2 : $error = "Provider not properly configured."; break; case 3 : $error = "Unknown or disabled provider."; break; case 4 : $error = "Missing provider application credentials."; break; case 5 : $error = "Authentification failed. The user has canceled the authentication or the provider refused the connection."; break; case 6 : $error = "User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again."; $adapter->logout(); break; case 7 : $error = "User not connected to the provider."; $adapter->logout(); break; } // well, basically you should not display this to the end user, just give him a hint and move on.. $error .= "Original error message: " . $e->getMessage(); $error .= "Trace: " . $e->getTraceAsString(); $this->set('error', $error); } } 

HybridAuth library is located in the webroot folder in the application folder

however, I get an error which is in case 6 ie

case 6: $ error = "User profile error. Most likely, the user is not connected to the provider, and he must authenticate again.";

Exact error message Undefined variable: adapter [APP\Controller\UsersController.php, line 177] , which points to CASE 6

Can someone tell me what is happening. I can't debug this.

PS This only happens with Google Login

Regards, Guns

+6
source share
1 answer

Your question is more than six months, but here you decide:

Go to https://console.developers.google.com/ and activate access to the Google+ API.

Today I ran into this problem and it worked!

+7
source

Source: https://habr.com/ru/post/958065/


All Articles