src/Ant/ChateaClient/Service/Client/ChateaOAuth2Client.php
public function withRefreshToken($refresh_token)
    {
        if (!is_string($refresh_token) || 0 >= strlen($refresh_token)) {
            throw new InvalidArgumentException("refresh_token must be a non-empty string");
        }

        $command = $this->getCommand('withRefreshToken',
            array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret(),'refresh_token'=>$refresh_token)
        );

        try{
            return $command->execute();
        }catch (ServerErrorResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch (BadResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch(ClientErrorResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch(CurlException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }
    }
public function withRefreshToken($refresh_token)
    {
        if (!is_string($refresh_token) || 0 >= strlen($refresh_token)) {
            throw new InvalidArgumentException("refresh_token must be a non-empty string");
        }

        $command = $this->getCommand('withRefreshToken',
            array('client_id'=>$this->getClientId(),'client_secret'=>$this->getSecret(),'refresh_token'=>$refresh_token)
        );

        try{
            return $command->execute();
        }catch (ServerErrorResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch (BadResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch(ClientErrorResponseException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }catch(CurlException $ex){
            throw new AuthenticationException($ex->getMessage(), 400, $ex);
        }
    }
public function withRefreshToken ( $ refresh_token ) { if ( ! is_string ( $ refresh_token ) || 0 >= strlen ( $ refresh_token ) ) { throw new InvalidArgumentException ( "refresh_token must be a non-empty string" ) ; } $ command = $ this -> getCommand ( 'withRefreshToken' , array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getSecret ( ) , 'refresh_token' => $ refresh_token ) ) ; try { return $ command -> execute ( ) ; } catch ( ServerErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( BadResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( ClientErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( CurlException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } }
After the client has been authorized for access, they can use a refresh token to get a new access token.

@param string $refresh_token The client refresh token that you obtain in first request of credentials.

@return array|string Associative array with client credentials | Message with error in json format

@throws InvalidArgumentException This exception is thrown if any parameter has errors

@throws AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

@example Get client credentials

$clientInstande->withRefreshToken('refresh-token-demo');

array("access_token"    => access-token-demo,
"expires_in"      => 3600,
"token_type"      => bearer,
"scope"           => password,
"refresh_token"   => refresh-token-demo
);
After the client has been authorized for access they can use a refresh token to get a new access token .