diff --git a/src/Server/Server.php b/src/Server/Server.php index f7b6bb1..63c94dc 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'); @@ -464,11 +466,16 @@ 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') { - 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();