Hybrid auth with Yii causing a redirect loop

 ̄綄美尐妖づ 提交于 2019-12-18 08:55:21

问题


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


回答1:


  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




回答2:


Did you noticed the base url in your config? Its where the callback is returned during auth and you must use live web domain to test it.

"base_url" => "http://localhost/yiiauth/authtest/",

Also twitter requires additional tokens to be created , i hope you have done that already.

I have working hybridauth on my test website: www.bemployable.com



来源:https://stackoverflow.com/questions/13024803/hybrid-auth-with-yii-causing-a-redirect-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!