Infusionsoft_App::updateAndSaveTokens PHP Method

updateAndSaveTokens() public method

public updateAndSaveTokens ( $accessToken, $refreshToken, $expiresIn )
    public function updateAndSaveTokens($accessToken, $refreshToken, $expiresIn)
    {
        $this->tokenStorageProvider->saveTokens($this->hostname, $accessToken, $refreshToken, $expiresIn);
        $this->accessToken = $accessToken;
        $this->refreshToken = $refreshToken;
        $this->tokenExpires = time() + $expiresIn;
        $this->client->extraUrlParams = array('access_token' => $this->accessToken);
    }

Usage Example

 public static function processAuthenticationScopeAndCode($scope, $code)
 {
     $parts = explode("|", $scope);
     $scope = array_shift($parts);
     $appDomain = array_shift($parts);
     $response = static::getToken($code);
     if (isset($response['error'])) {
         throw new Exception($response['error_description']);
     }
     /** @var Infusionsoft_App $app */
     $app = Infusionsoft_AppPool::getApp($appDomain);
     if ($app == null) {
         $app = new Infusionsoft_App($appDomain);
     }
     $app->updateAndSaveTokens($response['access_token'], $response['refresh_token'], $response['expires_in']);
     return true;
 }