{"record":{"id":"f31e083693e9fcef","repo":"Leantime/leantime","slug":"failed-to-retrieve-tokens","errorCode":null,"errorMessage":"Failed to retrieve tokens: ","messagePattern":"Failed to retrieve tokens: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"app/Domain/Oidc/Services/Oidc.php","lineNumber":347,"sourceCode":"    /**\n     * @throws GuzzleException\n     */\n    private function requestTokens(string $code): array|string\n    {\n        $httpClient = Http::withoutVerifying();\n\n        // Add proper client authentication headers\n        $response = $httpClient->asForm()->post($this->getTokenUrl(), [\n            'client_id' => $this->clientId,\n            'client_secret' => $this->clientSecret,\n            'grant_type' => 'authorization_code',\n            'code' => $code,\n            'redirect_uri' => $this->buildRedirectUrl(),\n        ]);\n\n        if ($response->failed()) {\n            Log::error('OIDC Token Request Failed: '.$response->body());\n            throw new \\RuntimeException('Failed to retrieve tokens: '.$response->body());\n        }\n\n        $headerArray = [];\n        foreach ($response->getHeaders() as $header => $values) {\n            $headerArray[strtolower($header)] = $values;\n        }\n        $contentType = array_pop($headerArray['content-type']);\n\n        switch ($contentType) {\n            case 'application/x-www-form-urlencoded; charset=utf-8':\n            case 'application/x-www-form-urlencoded':\n                $result = [];\n                parse_str($response->getBody()->getContents(), $result);\n\n                return $result;\n            default:\n                return json_decode($response->getBody()->getContents(), true);\n        }","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Domain/Oidc/Services/Oidc.php#L329-L365","documentation":"Error \"Failed to retrieve tokens: \" thrown in Leantime/leantime.","triggerScenarios":"Thrown at app/Domain/Oidc/Services/Oidc.php:347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}