0
votes

I've used Yii 2 authclient in my app and when i try it , it gives me

Unknown component ID: authClientCollection

the code i used in config\main.php

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

in login page :

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

any help please .

2

2 Answers

2
votes

You need to wrap this configuration in

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

which is CLEARLY stated in documentation.

0
votes

Try like so,

'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',
            ]
        ]