예제 #1
0
 /**
  * Authenticate given access code to get access token and refresh token
  * Save those to database
  * @param string $code access code
  */
 public function setAccessCode($code)
 {
     try {
         $oauthParams = $this->client->authenticate($code);
     } catch (\Exception $e) {
         return false;
     }
     $oauth = json_decode($oauthParams);
     if (!Settings::setAccessToken($oauthParams)) {
         return false;
     }
     if (isset($oauth->refresh_token)) {
         Settings::setRefreshToken($oauth->refresh_token);
     }
     return true;
 }