{"record":{"id":"3a470ef62e02c966","repo":"usebruno/bruno","slug":"no-access-token-received-from-server","errorCode":null,"errorMessage":"No access token received from server","messagePattern":"No access token received from server","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/auth/oauth2-helper.ts","lineNumber":386,"sourceCode":"    // Otherwise, proceed to fetch new token\n  }\n\n  let tokenResponse;\n\n  if (grantType === 'client_credentials') {\n    tokenResponse = await fetchTokenClientCredentials(oauth2Config, axiosInstance);\n  } else if (grantType === 'password') {\n    tokenResponse = await fetchTokenPassword(oauth2Config, axiosInstance);\n  } else {\n    throw new Error(`Unsupported grant type: ${grantType}`);\n  }\n\n  if (tokenResponse.error) {\n    throw new Error(JSON.stringify(tokenResponse));\n  }\n\n  if (!tokenResponse || !tokenResponse.access_token) {\n    throw new Error('No access token received from server');\n  }\n\n  if (tokenResponse.expires_in && tokenResponse.created_at) {\n    tokenResponse.expires_at = tokenResponse.created_at + tokenResponse.expires_in * 1000;\n  }\n\n  const saved = await tokenStore.saveCredential({ url: accessTokenUrl, credentialsId, credentials: tokenResponse });\n  if (!saved) {\n    console.warn('OAuth2: Failed to save token to store, but proceeding with token');\n  }\n\n  return tokenSource === 'id_token' ? tokenResponse.id_token : tokenResponse.access_token;\n};\n","sourceCodeStart":368,"sourceCodeEnd":400,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/auth/oauth2-helper.ts#L368-L400","documentation":"Thrown when the token endpoint returned a 2xx response that parsed cleanly and contained no 'error' field, but the body had no access_token. The helper cannot proceed because there is no credential to return or store.","triggerScenarios":"Token server returned 200 with an unexpected body shape (e.g. returned only an id_token, or returned the token under a non-standard key like 'accessToken'), or returned an empty object.","commonSituations":"Server misconfiguration returning the token under a camelCase key instead of access_token; partial response truncated by a proxy; the server issued only an id_token but tokenSource was left at its default 'access_token'; OAuth2 provider returning a non-RFC6749 compliant body.","solutions":["Inspect the raw token response (add logging before the helper or capture network traffic) to see what body the server actually returns.","If the server uses a non-standard key, normalize the response before relying on this helper, or open a provider-compatibility issue.","Confirm you are not hitting an HTML login page (200 + HTML) because the token URL points at the wrong endpoint.","If only an id_token is issued, set tokenSource:'id_token' — but note this error still fires because the access_token check happens first."],"exampleFix":"// before\nconst config = { grantType: 'client_credentials', accessTokenUrl: url, clientId: id, clientSecret: secret };\n// tokenResponse from server = { accessToken: '...' }  // non-standard key\n\n// after — point at the correct token endpoint that returns RFC6749 { access_token, token_type, expires_in }","handlingStrategy":"try-catch","validationCode":"// Cannot prevent from client side; pre-validate the URL points at the real token endpoint:\ntry { new URL(config.accessTokenUrl); } catch { throw new Error('accessTokenUrl is not a valid URL'); }","typeGuard":null,"tryCatchPattern":"try { await getOAuth2AccessToken(config, tokenStore); }\ncatch (e) {\n  if (e.message === 'No access token received from server') {\n    // capture the raw response separately to inspect its shape\n    console.error('Token endpoint did not return access_token; verify RFC6749 compliance');\n  } else throw e;\n}","preventionTips":["Confirm the token endpoint is the OAuth2 token URL, not a login page or JSON:API endpoint.","If the server returns a non-standard key, file a provider-compatibility issue or wrap the response.","Set tokenSource to 'id_token' only if the server actually issues id_tokens."],"tags":["oauth2","token-endpoint","server-error","runtime","rfc6749"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}