Prior March 2018 I had a web app (in development stage) working with yii2-authclient + facebook client and returning the user attributes. But after FB did some changes, now I don’t get anything. This is the code:
Configuration of the component:
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
//'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',
'returnUrl' => 'https://domain/store/access/sign/fb',
'clientId' => isset($keys['fbapp_id']) ? $keys['fbapp_id'] : null,
'clientSecret' => isset($keys['fbapp_secret']) ? $keys['fbapp_secret'] : null,
'attributeNames' => [
'name',
'email',
'first_name',
'last_name',
'gender',
'address',
'age_range',
'birthday',
'currency',
'devices',
'location',
'name_format',
'third_party_id',
'timezone',
'friends',
'picture',
],
'scope' => [
'email',
'public_profile',
'user_birthday',
'user_friends',
'user_hometown',
'user_location',
],
],
],
]
Controller:
'social' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'oAuthSuccess'],
],
/**
* This function will be triggered when user is successfuly authenticated using some oAuth client.
*
* @param yii\authclient\ClientInterface $client
* @return boolean|yii\web\Response
*/
public function oAuthSuccess($client)
{
// get user data from client
xdebug_break();
$userAttributes = $client->getUserAttributes(); // nothing returned here!!!!!!!
var_dump($userAttributes);
\Yii::$app->cache->set('fb', $userAttributes, '60');
// do some thing with user data. for example with $userAttributes['email']
}
View:
<div class="col-lg-8">
<!--?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' =--> ['auth/social']
]) ?>
</div>
Facebook: Configuration of the start session product attached.
Any help is appreciated.