Creating your own auth clients

Hi, I am reading the docs in Creating your own auth clients

I am confuse where should I put this script and how can I call them, the docs did not teach where to create and how to call this class.


use yii\authclient\OAuth2;


class MyAuthClient extends OAuth2

{

    protected function defaultName()

    {

        return 'my_auth_client';

    }


    protected function defaultTitle()

    {

        return 'My Auth Client';

    }


    protected function defaultViewOptions()

    {

        return [

            'popupWidth' => 800,

            'popupHeight' => 500,

        ];

    }

}


use yii\authclient\OAuth2;


class MyAuthClient extends OAuth2

{

    public $authUrl = 'https://www.my.com/oauth2/auth';


    public $tokenUrl = 'https://www.my.com/oauth2/token';


    public $apiBaseUrl = 'https://www.my.com/apis/oauth2/v1';


    protected function initUserAttributes()

    {

        return $this->api('userinfo', 'GET');

    }

}

Thank you in advance.

Anywhere you want, just follow PSR-4 to make your classes autoloadable.

You don’t have to instantiate these classes in your own code. Add them to the “authClientCollection” configuration and yii\authclient\AuthAction will call them when necessary.

can you please show how can I add here?




 'authClientCollection' => [

            'class' => 'yii\authclient\Collection',

            'clients' => [

                'google' => [

                    'class' => 'yii\authclient\clients\GoogleOAuth',

                    'clientId' => 'myclient_id',

                    'clientSecret' => 'xxxxxx',

                ],

                'facebook' => [

                    'class' => 'yii\authclient\clients\Facebook',

                    'clientId' => 'facebook_client_id',

                    'clientSecret' => 'facebook_client_secret',

                ],

            ],

        ],










 'authClientCollection' => [

            'class' => 'yii\authclient\Collection',

            'clients' => [

                'myclient' => [

                    'class' => 'app\authclients\MyAuthClient', // fully qualified classname

                    'clientId' => 'client_id',

                    'clientSecret' => 'client_secret',

                	// other configuration options

                ],

            ],

        ],



Ok thank you, I have last question. Is authclient will work in localhost ?