2016-08-10 1 views
0

J'ai créé un script de connexion avec HybridAuth. Je suis connecté sur mon site avec "fournisseurs" Facebook, Google, Twitter. Lorsque les sessions PHP expirent, je veux restaurer mes "fournisseurs" connectés.hybridauth - impossible de restaurer google login

J'utilise ce code:

$connected_adapters_list = $hybridauth->getConnectedProviders(); 
      if(count($connected_adapters_list)){ 
       foreach($connected_adapters_list as $adapter_id){ 
        echo $adapter_id . "<br>"; 
      } 
    } 

HybridAuth peut restaurer ma connexion Facebook et Twitter, mais pas Google. C'est la sortie d'erreur de code. Comment le résoudre ?

Ooophs, we got an error: User profile request failed! Google returned an invalid response:stdClass::__set_state(array('error' => stdClass::__set_state(array('errors' => array (0 => stdClass::__set_state(array('domain' => 'global', 'reason' => 'authError', 'message' => 'Invalid Credentials', 'locationType' => 'header', 'location' => 'Authorization',)),), 'code' => 401, 'message' => 'Invalid Credentials',)),)) Error code: 6 

Répondre

2

I a aussi ce problème,

il pourrait être sloved en utilisant "logoutAllProviders()" fonction

il y a code:

try{ 
     $hybridauth = new Hybrid_Auth($config); 

     $adapter = $hybridauth->authenticate("Google"); 
     $user_profile = $adapter->getUserProfile(); 

    } 
    catch(Exception $e){ 
     $hybridauth->logoutAllProviders(); 
     $hybridauth = new Hybrid_Auth($config);   
     $adapter = $hybridauth->authenticate("Google"); 
     $user_profile = $adapter->getUserProfile(); 
    } 
} 

bonne chance pour vous!