/**
  * Returns the select authentification provider
  * @return \Hybridauth\Adapter\AdapterInterface
  */
 private function getProvider()
 {
     $uri = $this->getRequest()->getUri();
     $base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
     $provider = $this->getRequest()->getQuery('provider');
     $config = $this->hybridauthConfiguration;
     $config['callback'] = $base . $this->url()->fromRoute('theodia.rpc.hybrid-auth', ['action' => 'callback']) . '?provider=' . $provider;
     $hybridauth = new \Hybridauth\Hybridauth($config);
     $adapter = $hybridauth->getAdapter($provider);
     return $adapter;
 }
Beispiel #2
0
<?php

$config = dirname(__FILE__) . "/config.php";
require_once dirname(__FILE__) . "/../src/Hybridauth/Hybridauth.php";
\Hybridauth\Hybridauth::registerAutoloader();
try {
    $hybridauth = new \Hybridauth\Hybridauth($config);
    $adapter = $hybridauth->authenticate("Google");
    // $adapter = $hybridauth->authenticate( "Facebook" );
    // $adapter = $hybridauth->authenticate( "Windows" );
    // $adapter = $hybridauth->authenticate( "Twitter" );
    // $adapter = $hybridauth->authenticate( "Yahoo" );
    // $adapter = $hybridauth->authenticate( "LinkedIn" );
    // $adapter = $hybridauth->authenticate( "OpenID", array( "openid_identifier" => "https://open.login.yahooapis.com/openid20/www.yahoo.com/xrds" ) );
    // request user profile
    $user_profile = $adapter->getUserProfile();
    // user profile
    echo "<pre>" . print_r($user_profile, true) . "</pre>";
    echo $adapter->debug();
    // echo "Logging out..";
    $adapter->disconnect();
} catch (Exception $e) {
    echo $e;
}
Beispiel #3
0
<?php

$config = dirname(__FILE__) . "/config.php";
require_once dirname(__FILE__) . "/../src/Hybridauth/Hybridauth.php";
\Hybridauth\Hybridauth::registerAutoloader();
try {
    $hybridauth = new \Hybridauth\Hybridauth($config);
    $adapter = $hybridauth->getAdapter("Google");
    $adapter->setApplicationId('**.apps.googleusercontent.com');
    $adapter->setApplicationSecret('**');
    $adapter->setApplicationScope('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email');
    $adapter->setEndpointAuthorizeUri('https://accounts.google.com/o/oauth2/auth');
    $adapter->setEndpointRequestTokenUri('https://accounts.google.com/o/oauth2/token');
    $adapter->setEndpointTokenInfoUri('https://www.googleapis.com/oauth2/v1/tokeninfo');
    $adapter->setEndpointAuthorizeUriAdditionalParameters(array('access_type' => 'offline'));
    $adapter->authenticate();
    $user_profile = $adapter->getUserProfile();
    echo "<pre>" . print_r($user_profile, true) . "</pre>";
    echo $adapter->debug();
    $adapter->disconnect();
} catch (\Hybridauth\Exception $e) {
    echo $e;
}