Hybrid auth error on login "No provider ID specified."

1.3k views Asked by At

I am using Hybrid Auth to login to facebook, twitter and linkedin but at first i get exception "No provider ID specified." but when i go back and try again it works fine weird :(. here's my code

{
  session_start();
  $config = dirname(__FILE__).
  '/hybridauth/config.php';
  require_once("hybridauth/Hybrid/Auth.php");
  $db = new DB_Functions();
  try {
    // echo "store provider in session";
    $_SESSION["provider"] = $_POST["provider"];
    $provider = $_POST["provider"];
    //echo " init hauth\n";
    $hybridauth = new Hybrid_Auth($config);

    // authenticate the current user with Twitter
    //echo "before login\n"+$provider;
    $auth_provider = $hybridauth - > authenticate($_POST["provider"]);
    // $hybridauth = new Hybrid_Auth( $config ); 
    //echo "after login\n"; 
    // echo "get hauth session";
    //  echo $_POST["provider"];
    $hybridauth_session_data = $hybridauth - > getSessionData();
    // echo (string)$hybridauth_session_data;

    //GET UNIQUE INDENTIFIER FROM USER PROFILE
    //   echo "get user ID";
    $user_profile = $auth_provider - > getUserProfile();
    $identifier = $user_profile - > profileURL;
    if (!$db - > isUserExisted($identifier)) {
      // then store it on your database or somethin
      $res = $db - > store_hybridauth_session($_SESSION["provider"], $hybridauth_session_data, $identifier);
      // echo "<br/> DB insert query Result:".$res." mysqli error: ".mysqli_error();
      $auth_provider - > logout();
  //redirect
    } else {
      $auth_provider - > logout();
  //redirect
    }
  } catch (Exception $e) {
    echo "Ooophs, we got an error: ".$e - > getMessage().
    " go back and try again";
  }
}
any help would be greatly appreciated :) thanks in advance

1

There are 1 answers

0
Murugan Vellaisamy On BEST ANSWER

I found your error.this error in auth.php file. That file contains like this code below

    <?php 
return array(

"base_url" => "http://www.gling.in/oauth2callback/auth",
"providers"=>array(
"Google"=> array(
"enabled" =>TRUE,
"keys" =>array("id"=>"34845538gd7t45fgdfg8787fdgdf2462-mi5jh8cemle7dagr8a8317eggddglmg2.apps.googleusercontent.com",
"secret"=>"2BAOtrtrttr1fdgdegdgdfgdA5fA6dsfdsfdsXnYAdriuYpKzh8HVSi"),
"scope"=>"https://www.googleapis.com/auth/userinfo.profile,email"."https://www.googleapis.com/auth/userinfo.email "
)
)
);

So you should did mistake in this place google. you want to change your social network.. if you are using facebook,you must put in this place Facebook.Thank you.