Search code examples
cakephpcakephp-2.0cakephp-2.3google-authenticationhybridauth

CakePHP configuring HybidAuth google provider


I am using HybridAuth. I have already configured vkontaknte and facebook providers. Now I need additional one - google.

Below the part of my config hybridAuth:

  'Google' => array ( 
          "enabled" => true,
          "keys"    => array ( "id" => "my_id", "secret" => "my_secret_key" ),
          "scope"           => "https://www.googleapis.com/auth/userinfo.profile ". // optional
                               "https://www.googleapis.com/auth/userinfo.email"   ,
          "logo"    => '/img/vk.png',
          "class"   => 'Vkontaktelogo',
          "redirect_uri" => 'http://urdk.ru/hybridauth/?hauth.done=google',    
      ),

Once I press login "facebook" button, It redirects me to the google and ask me for scope list. It`s ok. But then It redirects me back to website, but login isnt completed.

I put my hybridAuth log. Could you ask me what is wrong?

log is here http://pastebin.com/J8G4htFj

Thx


Solution

  • I think my answer will be usefull for those peoples who use CakePHP hybridAuth library https://github.com/ADmad/CakePHP-HybridAuth/tree/cake2

    1) set Redirect URIs parameter with value "http:/mydomain.com/hybrid_auth/hybrid_auth/endpoint?hauth.done=google"

    2) set the same value for "redirect_uri" in the hybridauth.php (config)

    3) go to app/Vendor/hybridauth/Hybrid/Providers/Google.php find string

       $this->api->curl_header = array("Authorization: OAuth " . $this->access_token);
    

    and change it to

    $this->api->curl_header = array("Authorization: OAuth " . $this->api->access_token);
    

    That`s fixed an issue.