{"record":{"id":"115b79066be8fc05","repo":"FlowiseAI/Flowise","slug":"failed-to-retrieve-access-token-response-missing","errorCode":null,"errorMessage":"Failed to retrieve access token: Response missing access_token field","messagePattern":"Failed to retrieve access token: Response missing access_token field","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/MCP/Pipedream/PipedreamMCP.ts","lineNumber":220,"sourceCode":"\n        try {\n            const body: Record<string, string> = {\n                grant_type: 'client_credentials',\n                client_id: clientId,\n                client_secret: clientSecret\n            }\n            if (scope) {\n                body.scope = scope\n            }\n            const response = await axios.post('https://api.pipedream.com/v1/oauth/token', body, {\n                headers: {\n                    'Content-Type': 'application/json'\n                }\n            })\n\n            const accessToken = response.data?.access_token\n            if (!accessToken) {\n                throw new Error('Failed to retrieve access token: Response missing access_token field')\n            }\n\n            const expiresIn = response.data?.expires_in ?? 3600\n            tokenCache.set(tokenCacheKey, {\n                token: accessToken,\n                expiresAt: Date.now() + expiresIn * 1000\n            })\n\n            return accessToken\n        } catch (error: any) {\n            if (error.response?.status === 401) {\n                tokenCache.delete(tokenCacheKey)\n                throw new Error('Invalid Pipedream credentials. Please verify your Client ID and Client Secret.')\n            }\n            const message = error.message ?? 'Unknown error'\n            const code = error.code ?? error.response?.status ?? 'UNKNOWN'\n            throw new Error(`Pipedream OAuth token request failed [${code}]: ${message}`)\n        }","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/MCP/Pipedream/PipedreamMCP.ts#L202-L238","documentation":"Thrown by PipedreamMCP.fetchAccessToken after the OAuth token exchange to https://api.pipedream.com/v1/oauth/token succeeds (HTTP 200) but the response body has no access_token field. The client-credentials grant returned a payload that is missing the expected token, so the code cannot proceed to cache or use a token.","triggerScenarios":"A successful POST to Pipedream's /v1/oauth/token where response.data is null/undefined, an unexpected JSON shape, or response.data.access_token is empty string — for example an upstream API contract change, a proxy returning an HTML error page with 200, or a malformed response.","commonSituations":"Pipedream API changes its token response schema; an intermediary (corporate proxy, gateway) returns a 200 with a non-JSON body; axios transforms the response unexpectedly; the endpoint returns a partial object under load.","solutions":["Log response.status and response.data to confirm what Pipedream actually returned.","Check Pipedream status/changelog for a token-endpoint response format change.","Ensure no proxy is rewriting the response body; call the endpoint directly to compare.","If the body shape changed, update the access_token extraction path in fetchAccessToken accordingly."],"exampleFix":"// before\nconst accessToken = response.data?.access_token\nif (!accessToken) {\n    throw new Error('Failed to retrieve access token: Response missing access_token field')\n}\n// after (diagnostic, then fix extraction if shape changed)\nconsole.error('Pipedream token response:', response.status, JSON.stringify(response.data))\nconst accessToken = response.data?.access_token || response.data?.token\nif (!accessToken) {\n    throw new Error('Failed to retrieve access token: Response missing access_token field')\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasAccessTokenField(data: unknown): boolean {\n    return typeof data === 'object' && data !== null\n        && typeof (data as any).access_token === 'string'\n        && (data as any).access_token.length > 0\n}","tryCatchPattern":"try {\n    const token = await pipedream.fetchAccessToken(clientId, clientSecret, scope)\n} catch (e) {\n    if (e instanceof Error && e.message.startsWith('Failed to retrieve access token')) {\n        // log response shape, alert ops; this is an upstream contract issue, not a user fix\n    }\n}","preventionTips":["Pin/monitor the Pipedream API contract; add an integration test that asserts access_token is present.","Log response.status with response.data on failure to speed diagnosis.","Treat this error as a candidate incident rather than a user-config problem."],"tags":["pipedream","oauth","authentication","api-contract","network"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}