The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist changyuan/yii2-authclient
or add
"changyuan/yii2-authclient": "~2.1.0"
to the require
section of your composer.json.
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'weibo' => [
'class' => 'changyuan\authclient\clients\Weibo',
'clientId' => 'wb_key',
'clientSecret' => 'wb_secret',
],
'qq' => [
'class' => 'changyuan\authclient\clients\QQ',
'clientId' => 'qq_appid',
'clientSecret' => 'qq_appkey',
],
'wechat' => [
'class' => 'changyuan\authclient\clients\Wechat',
'clientId' => 'weixin_appid',
'clientSecret' => 'weixin_appkey',
],
'wechatmp' => [
'class' => 'changyuan\authclient\clients\Wechat',
'type' => 'mp',
'clientId' => 'weixin_appid',
'clientSecret' => 'weixin_appkey',
],
],
]
// other components
]
//The first way in view:
<?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' => ['site/auth']
]); ?>
//The second way in view:
<?php
use yii\authclient\widgets\AuthChoice;
?>
<?php $authAuthChoice = AuthChoice::begin([
'baseAuthUrl' => ['site/auth']
]); ?>
<ul>
<?php foreach ($authAuthChoice->getClients() as $client): ?>
<li><?= $authAuthChoice->clientLink($client) ?></li>
<?php endforeach; ?>
</ul>
<?php AuthChoice::end(); ?>
Q: this error "Invalid auth state parameter." ?
A: remove sub class $this->removeState('authState');