In oder to acquire access token perform following sequence:
php
use yii\authclient\OAuth2;
assuming class MyAuthClient extends OAuth2
$oauthClient = new MyAuthClient();
$url = $oauthClient->buildAuthUrl(); // Build authorization URL
Yii::$app->getResponse()->redirect($url); // Redirect to authorization URL.
After user returns at our site:
$code = $_GET['code'];
$accessToken = $oauthClient->fetchAccessToken($code); // Get access token