[SOLVED] AuthAction (GoogleOAuth) does not provide refresh_token

I’m using Google login with several scopes (email, calendar etc).

Everything is working good.

However, if the access_token expires, I need refresh_token in order to get new one but can’t see it.

Google Oauth server gives the refresh_token only at the first access, I know this and I’m clearing my “authorized access app” every time I’m testing.

But whatever I do, I can’t see from where I can get the refresh_token in Yii2 core functionality.

In AuthAction successCallback the $client is provided and it have everything but refresh_token.

Not sure if I’m missing a step, but will be very nice if someone can give a hint about this.

Just for example, this is returning the token object with no probs until expired:




$auth = Yii::$app->authClientCollection->getClient('google');

$token = $auth->getAccessToken();



From the code I can see that if it was expired already, it is trying to refresh it, but without success after some time.

Thanks!

Solved.

In the authClientCollection I need access_type=offline:




'authClientCollection' => [

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

			'clients' => [

				'google' => [

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

					'authUrl' => 'https://accounts.google.com/o/oauth2/auth?access_type=offline',

					'clientId' => '',

					'clientSecret' => '',

					'scope'	=> '',

				],

			],

		],