I'm getting error like
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: yii\authclient\clients\Twitter::requestEmail
Whenever I am including 'requestEmail' => 'true',
in 'authClientCollection' => [
for components
in web.php
web.php
$config = [
.
.
'components' => [
.
.
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'twitter' => [
'class' => 'yii\authclient\clients\Twitter',
'requestEmail' => 'true',
'consumerKey' => 'IFK2OMG0rKIFK2Jt4rLvw',
'consumerSecret' => 'ImTprQzaOMG0rKZsZiPDIvwIFK2aOMG0rKZsZiPD',
],
],
],
],
UsersController.php (Controller)
class UsersController extends CommonController
{
.
.
public function actions() {
return [
.
.
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'oAuthSuccess'],
],
];
}
.
.
public function oAuthSuccess($client) {
// get user data from client
$userAttributes = $client->getUserAttributes();
var_dump($userAttributes); die;
// do some thing with user data. for example with $userAttributes['email']
}
}
login.php (View)
.
.
<p class="text-center">
<?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' => ['/users/users/auth']
]) ?>
</p>
.
.
But, as soon I'm omitting the line 'requestEmail' => 'true',
from web.php. It's working. I'm getting all required data except email
. But, problem is : I am not getting email
of user trying to login. Any idea, how can i get. Any hint/suggestion will be a great help for me. Thanks.