From b06804b86c873fde865ff5b86f3a806c567bad8d Mon Sep 17 00:00:00 2001 From: Sergey Skaridov Date: Fri, 12 Jul 2024 14:58:50 +0000 Subject: [PATCH 1/2] add additional data to the credentials exception --- src/Server/Server.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Server/Server.php b/src/Server/Server.php index f7b6bb1..2e00999 100644 --- a/src/Server/Server.php +++ b/src/Server/Server.php @@ -103,6 +103,8 @@ public function getTemporaryCredentials() return $this->createTemporaryCredentials((string) $response->getBody()); } catch (BadResponseException $e) { $this->handleTemporaryCredentialsBadResponse($e); + } catch (CredentialsException $e) { + throw $e; } throw new CredentialsException('Failed to get temporary credentials'); @@ -468,7 +470,12 @@ protected function createTemporaryCredentials($body) } if ( ! isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') { - throw new CredentialsException('Error in retrieving temporary credentials.'); + foreach (['oauth_token', 'oauth_token_secret'] as $responseKey) { + if (isset($data[$responseKey])) { + $data[$responseKey] = 'hidden'; + } + } + throw new CredentialsException('Error in retrieving temporary credentials. Data:' . json_encode($data)); } $temporaryCredentials = new TemporaryCredentials(); From 8c95cfec840015015ad63b113f87e917c08e9b57 Mon Sep 17 00:00:00 2001 From: Sergey Skaridov Date: Wed, 21 Aug 2024 16:14:42 +0200 Subject: [PATCH 2/2] Update Server.php --- src/Server/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server/Server.php b/src/Server/Server.php index 2e00999..63c94dc 100644 --- a/src/Server/Server.php +++ b/src/Server/Server.php @@ -466,7 +466,7 @@ protected function createTemporaryCredentials($body) parse_str($body, $data); if ( ! $data || ! is_array($data)) { - throw new CredentialsException('Unable to parse temporary credentials response.'); + throw new CredentialsException('Unable to parse temporary credentials response. Data:' . serialize($data)); } if ( ! isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {