{"record":{"id":"f86455f18f370a8f","repo":"usebruno/bruno","slug":"access-token-url-is-required-for-oauth2-client-cre","errorCode":null,"errorMessage":"Access Token URL is required for OAuth2 client credentials flow","messagePattern":"Access Token URL is required for OAuth2 client credentials flow","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/auth/oauth2-helper.ts","lineNumber":122,"sourceCode":"    return data;\n  }\n};\n\n/**\n * Fetches an OAuth2 token using client credentials grant\n */\nconst fetchTokenClientCredentials = async (oauth2Config: OAuth2Config, axiosInstance?: AxiosInstance) => {\n  const {\n    accessTokenUrl,\n    clientId,\n    clientSecret,\n    scope,\n    credentialsPlacement = 'basic_auth_header',\n    additionalParameters\n  } = oauth2Config;\n\n  if (!accessTokenUrl) {\n    throw new Error('Access Token URL is required for OAuth2 client credentials flow');\n  }\n\n  if (!clientId) {\n    throw new Error('Client ID is required for OAuth2 client credentials flow');\n  }\n\n  const requestConfig: RequestConfig = {\n    method: 'POST',\n    url: accessTokenUrl,\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded',\n      'Accept': 'application/json'\n    },\n    data: '',\n    responseType: 'arraybuffer'\n  };\n\n  const data: ClientCredentialsData = {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/auth/oauth2-helper.ts#L104-L140","documentation":"Thrown by fetchTokenClientCredentials when the OAuth2Config.accessTokenUrl field is empty/undefined. The client-credentials grant needs a token endpoint to POST credentials to, so the helper refuses to build a request without one. It is a pre-flight validation guard, not a network error.","triggerScenarios":"Calling getOAuth2AccessToken (or the Bruno auth pipeline) with grantType='client_credentials' but accessTokenUrl set to '', null, undefined, or omitted. This includes configs loaded from a collection where the token URL field was left blank by the user.","commonSituations":"User created an OAuth2 collection item but never filled the 'Access Token URL' field; env variable referencing the URL resolved to empty; config object assembled programmatically and the accessTokenUrl key was misspelled or destructured away.","solutions":["Set oauth2Config.accessTokenUrl to the full token endpoint URL (e.g. https://auth.example.com/oauth/token) before invoking the flow.","If the URL comes from an env var, verify the variable is defined and non-empty at call time (console.log it in dev).","Add a pre-call validation check (see validationCode) so the error surfaces in your code, not inside the helper."],"exampleFix":"// before\nconst config = { grantType: 'client_credentials', clientId: 'abc', clientSecret: 'xyz' };\nawait getOAuth2AccessToken(config, tokenStore);\n\n// after\nconst config = {\n  grantType: 'client_credentials',\n  accessTokenUrl: process.env.OAUTH_TOKEN_URL,\n  clientId: 'abc',\n  clientSecret: 'xyz'\n};\nawait getOAuth2AccessToken(config, tokenStore);","handlingStrategy":"validation","validationCode":"function validateClientCredentialsConfig(c) {\n  if (!c.accessTokenUrl) throw new Error('accessTokenUrl missing for client_credentials flow');\n  if (!c.clientId) throw new Error('clientId missing for client_credentials flow');\n}\nvalidateClientCredentialsConfig(config);","typeGuard":"function isClientCredentialsReady(c) {\n  return c.grantType === 'client_credentials'\n    && typeof c.accessTokenUrl === 'string' && c.accessTokenUrl.length > 0\n    && typeof c.clientId === 'string' && c.clientId.length > 0;\n}","tryCatchPattern":"try { await getOAuth2AccessToken(config, tokenStore); }\ncatch (e) { if (e.message.includes('Access Token URL is required')) { /* fill config */ } else throw e; }","preventionTips":["Build OAuth2Config through a factory that asserts required fields per grant type.","Resolve env-var substitutions for URLs before passing the config to the helper.","Run a config-shape unit test that exercises both grant types."],"tags":["oauth2","validation","configuration","client-credentials"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}