Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

php - Hybrid auth with Yii causing a redirect loop

I am trying to implement twitter sign in on my website using hybridauth. I know there is a hybrid auth plugin for Yii. I am not using it because last time I used I ran into some problems. I am trying to implement the core version of hybrid auth.

I am calling

$hybridauth = new Hybrid_Auth( Yii::app()->params['hybridauth'] );
$adapter = $hybridauth->authenticate( 'Twitter');

But for some reason it redirects to http://localhost/yiiauth/authtest/?hauth.start=Twitter&hauth.time=1350973441 , which causes a redirect loop. Is there any way to solve this problem ? My hybrid auth configuration is as follows :

'params'=>array(

    'hybridauth'=>array(
        "base_url" => "http://localhost/yiiauth/authtest/", 

        "providers" => array ( 
            "Twitter" => array ( 
                "enabled" => true,
                "keys"    => array ( "key" => "mykey", "secret" => "mysecret" ) 
            ),
        ),


        "debug_mode" => false,

        "debug_file" => "",
    )
),

My hybridauth files are in /protected/extensions/hybridauth and I include the Hybrid/Auth.php in the top of the index.php file

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Hybrid Auth login for twitter and facebook requires a valid domain not localhost.

  2. Your base_url in configuration file "hybridauth.php" should be set to "/hauth/endpoint" i.e. it must point to the endpoint. If you have removed index.php through .htaccess then use "/index.php/hauth/endpoint".

  3. Set permissions of hybridauth.log in Logs folder to writable.

Reference Link: http://hybridauth.sourceforge.net/userguide/Configuration.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...