Not sure an extension is needed since it’s working really nice with Google apiclient library (composer: google/apiclient)
And only several lines of code are needed.
public function actionAuthenticate()
{
$scriptUri = Yii::$app->urlManager->createAbsoluteUrl(['site/authenticate']);
$client = new \Google_Client();
$client->setAccessType('online');
$client->setClientId(Yii::$app->params['googleOauth']['clientId']);
$client->setClientSecret(Yii::$app->params['googleOauth']['clientSecret']);
$client->setRedirectUri($scriptUri);
$client->setScopes(Yii::$app->params['googleOauth']['scopes']);
if (isset($_GET['code'])) { // we received the positive auth callback, get the token and store it in session
$client->authenticate($_GET['code']);
Yii::$app->session->set('token', $client->getAccessToken());
}
if (Yii::$app->session->get('token')) { // extract token from session and configure client
$client->setAccessToken(Yii::$app->session->get('token'));
}
if (!$client->getAccessToken() || $client->isAccessTokenExpired()) { // auth call to google
$authUrl = $client->createAuthUrl();
header("Location: ".$authUrl);
die;
}
//do some API call with the given $client
//...
}