Yii2:authclient

时间:2017-03-05 11:01:26

标签: php yii2 facebook-login yii2-advanced-app

我在我的应用中使用了Yii 2 authclient,当我尝试时,它给了我

  

未知组件ID:authClientCollection

我在config \ main.php中使用的代码

 'facebook' => [
        'class' => 'yii\authclient\clients\Facebook',
        'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',
        'clientId' => '1796624797324840', // my app id from facebook.
        'clientSecret' => 'My App Secret',
    ],
登录页面中的

 <?= yii\authclient\widgets\authChoice::widget(['baseAuthUrl'=>['site/auth']]) ?>

请帮助。

2 个答案:

答案 0 :(得分:2)

您需要将此配置包装在

'authClientCollection' => [
    'class' => 'yii\authclient\Collection',
    'clients' => [
        // add your facebook config here
    ],
],

CLEARLY stated in documentation

答案 1 :(得分:0)

尝试这样,

'facebook' => [
            'class' => yii\authclient\clients\Facebook::class,
            'clientId' => 'YOUR_FACEBOOK_CLIENT_ID',
            'clientSecret' => 'YOUR_FACEBOOK_CLIENT_SECRET',
            'scope' => 'email,public_profile',
            'attributeNames' => [
                'name',
                'email',
                'first_name',
                'last_name',
            ]
        ]