Skip to content

Instantly share code, notes, and snippets.

@phamngsinh
Created July 18, 2016 03:02
Show Gist options
  • Select an option

  • Save phamngsinh/cc09716a77290f9401463f703d725ec0 to your computer and use it in GitHub Desktop.

Select an option

Save phamngsinh/cc09716a77290f9401463f703d725ec0 to your computer and use it in GitHub Desktop.
Refresh token in laravel
Step 1:
install https://github.com/oriceon/oauth-5-laravel
Step 2 :
get token and follow the instructions: https://github.com/oriceon/oauth-5-laravel
Step 3 :
token expired and should reset
$user = User::find($userId);
$token_interface = new \OAuth\OAuth2\Token\StdOAuth2Token($google_token, $google_refresh_token);
$googleService = \OAuth::consumer('Google');
$token = $googleService->refreshAccessToken($token_interface);
$user->google_token = $token->getAccessToken();
$user->google_token_expire = $this->getProtectedValue($token, 'endOfLife');
$user->save();
return $user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment