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');
}
}
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.