From ebcf98d260ca40589e845375a5a24e3b3d2f592c Mon Sep 17 00:00:00 2001 From: Kevin Thrailkill Date: Mon, 3 May 2021 14:12:12 -0700 Subject: [PATCH 1/2] Updated restforce so that a user can refresh a token from the application using it --- src/Rest/OAuthRestClient.php | 8 ++++++++ src/Rest/RestClientInterface.php | 2 ++ src/Restforce.php | 5 +++++ src/RestforceInterface.php | 2 ++ 4 files changed, 17 insertions(+) diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 72eb891..02e61e6 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -100,6 +100,14 @@ 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 @@ Date: Mon, 3 May 2021 14:17:53 -0700 Subject: [PATCH 2/2] Update OAuthRestClient.php Linking to clubhouse story [ch106979] --- src/Rest/OAuthRestClient.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 02e61e6..3b2a379 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -108,6 +108,7 @@ public function refreshToken(): OAuthAccessToken return $refreshedToken; } + private function setParamsFromAccessToken(): void { $this->apiRestClient->setBaseUriForRestClient($this->getOAuthAccessToken()->getInstanceUrl());