diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 72eb891..3b2a379 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -100,6 +100,15 @@ public function patchJson( ); } + public function refreshToken(): OAuthAccessToken + { + $refreshToken = $this->oAuthAccessToken->getRefreshToken(); + $refreshedToken = $this->getRefreshToken($refreshToken); + $this->oAuthAccessToken = $refreshedToken; + return $refreshedToken; + } + + private function setParamsFromAccessToken(): void { $this->apiRestClient->setBaseUriForRestClient($this->getOAuthAccessToken()->getInstanceUrl()); diff --git a/src/Rest/RestClientInterface.php b/src/Rest/RestClientInterface.php index f3530ce..2cb9cc0 100644 --- a/src/Rest/RestClientInterface.php +++ b/src/Rest/RestClientInterface.php @@ -32,4 +32,6 @@ public function patchJson( array $headers = [], ?float $timeoutSeconds = null ): ResponseInterface; + + public function refreshToken(): OAuthAccessToken; } diff --git a/src/Restforce.php b/src/Restforce.php index 789bcbe..7683ba3 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -119,6 +119,11 @@ public function query(string $queryString): ResponseInterface ]); } + public function refreshToken(): OAuthAccessToken + { + return $this->getOAuthRestClient()->refreshToken(); + } + public function userInfo(): ResponseInterface { return $this->getOAuthRestClient()->get(self::USER_INFO_ENDPOINT); diff --git a/src/RestforceInterface.php b/src/RestforceInterface.php index c13b4dd..4c1019a 100644 --- a/src/RestforceInterface.php +++ b/src/RestforceInterface.php @@ -1,6 +1,7 @@