diff --git a/src/VCS/Adapter/Git/GitHub.php b/src/VCS/Adapter/Git/GitHub.php index 608712e0..403e874f 100644 --- a/src/VCS/Adapter/Git/GitHub.php +++ b/src/VCS/Adapter/Git/GitHub.php @@ -636,8 +636,10 @@ protected function generateAccessToken(string $privateKey, ?string $appId): void $this->jwtToken = $token; $response = $this->call(self::METHOD_POST, '/app/installations/' . $this->installationId . '/access_tokens', ['Authorization' => 'Bearer ' . $token]); $responseBody = $response['body'] ?? []; + $statusCode = $response['headers']['status-code'] ?? 0; if (!array_key_exists('token', $responseBody)) { - throw new Exception('Failed to retrieve access token from GitHub API.'); + $safeBody = \is_array($responseBody) ? \json_encode(\array_intersect_key($responseBody, \array_flip(['message', 'documentation_url']))) : ''; + throw new Exception('Failed to retrieve access token from GitHub API. Status: ' . $statusCode . '. Response: ' . $safeBody); } $this->accessToken = $responseBody['token'] ?? ''; }