Yii2 Bootstrap 3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Antonio Ramirez 3577b5c95a Fixed typo 11 years ago
..
clients Documentation at "yii\authclient" updated. 11 years ago
signature Extension "authclient" recomposed. 11 years ago
views "yii\authclient" structure refactored. 11 years ago
widgets minor doc fix. 11 years ago
AuthAction.php Doc comments at "yii\authclient" updated. 11 years ago
BaseClient.php Auth clients "Choice" widget markup updated. 11 years ago
BaseOAuth.php OAuth classes refactored. 11 years ago
ClientInterface.php Doc comments in "authclient" extension updated. 11 years ago
Collection.php Doc comments at "yii\authclient" updated. 11 years ago
LICENSE.md Extension "authclient" added as draft. 11 years ago
OAuth1.php Doc comments in "authclient" extension updated. 11 years ago
OAuth2.php OAuth classes refactored. 11 years ago
OAuthToken.php Extension "authclient" recomposed. 11 years ago
OpenId.php Doc comments in "authclient" extension updated. 11 years ago
README.md Fixed typo 11 years ago
composer.json Extension "authclient" added as draft. 11 years ago

README.md

AuthClient Extension for Yii 2

This extension adds OpenID, OAuth and OAuth2 consumers for the Yii 2 framework.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require yiisoft/yii2-authclient "*"

or add

"yiisoft/yii2-authclient": "*"

to the require section of your composer.json.

Usage & Documentation

This extension provides the ability of the authentication via external credentials providers. It covers OpenID, OAuth1 and OAuth2 protocols.

You need to setup auth client collection application component:

'components' => [
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'google' => [
                'class' => 'yii\authclient\clients\GoogleOpenId'
            ],
            'facebook' => [
                'class' => 'yii\authclient\clients\Facebook',
                'clientId' => 'facebook_client_id',
                'clientSecret' => 'facebook_client_secret',
            ],
        ],
    ]
    ...
]

Then you need to add yii\authclient\AuthAction to some of your web controllers:

class SiteController extends Controller
{
    public function actions()
    {
        return [
            'auth' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
            ],
        ]
    }

    public function successCallback($client)
    {
        $attributes = $client->getUserAttributes();
        // user login or signup comes here
    }
}

You may use yii\authclient\widgets\Choice to compose auth client selection:

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