我在我的应用中使用了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']]) ?>
请帮助。
答案 0 :(得分:2)
您需要将此配置包装在
中'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
// add your facebook config here
],
],
答案 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',
]
]