i’m using
I’m getting access_token and refresh_token after authentication but I want to refresh a token after its expiry, which I’m not able to find a way to do or any method in the library, any help would be appreciated.
/*Google OR Azure */
switch ($provider) {
case 'google':
$scopes = [
'https://www.googleapis.com/auth/plus.business.manage',
// 'https://graph.microsoft.com/user.read',
/*List of scopes to add if needed */
];
$parameters = ['access_type' => 'offline', "prompt" => "consent select_account"];
break;
case 'azure':
$scopes = [
'offline_access openid',
'https://graph.microsoft.com/user.read',
];
$parameters = ['access_type' => 'offline_access'];
break;
}
return Socialite::driver($provider)->scopes($scopes)->with($parameters)->stateless()->redirect();
public function handleProviderCallback()
{
$providerUser = Socialite::driver('azure')->stateless()->user();
return $data = [
'status' => 'success',
'access_token' => $providerUser->token,
'refresh_token' => $providerUser->refreshToken,
'expiry_time' => $providerUser->expiresIn,
'auth_provider' => 'azure',
'email' => $providerUser->email
];
}
i have tried a couple of ways but none of them seems to work for me as below
// $a = Socialite::driver('azure')->refreshToken($refToken);
// $a = (object) Socialite::driver('azure')
// ->setScopes(['offline_access'])
// ->getRefreshTokenResponse($refToken);
// $a= (object) Socialite::driver('azure')->user();
//$a= (object) Socialite::driver('azure')->getAccessToken();
// $a= Socialite::driver('azure')->stateless()->user();
// $a= Socialite::driver('azure')->userFromToken($accessToken);
//$a= Socialite::driver('twitch')->refreshToken($storedRefreshToken)
print_r($a);