{"record":{"id":"96d7c2630afdd8c2","repo":"Budibase/budibase","slug":"sharepoint-requires-an-oauth2-client-credentials-a","errorCode":null,"errorMessage":"SharePoint requires an OAuth2 client credentials auth config.","messagePattern":"SharePoint requires an OAuth2 client credentials auth config\\.","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts","lineNumber":178,"sourceCode":"const readConnection = async (\n  datasourceId: string,\n  authConfigId: string\n): Promise<OAuth2RestAuthConfigWithTokenCache> => {\n  let datasource: Datasource\n  try {\n    datasource = await sdk.datasources.get(datasourceId)\n  } catch {\n    throw new HTTPError(\"SharePoint auth config not found.\", 400)\n  }\n  const authConfigs = datasource.config?.authConfigs as\n    | OAuth2RestAuthConfigWithTokenCache[]\n    | undefined\n  const authConfig = authConfigs?.find(config => config._id === authConfigId)\n  if (!authConfig) {\n    throw new HTTPError(\"SharePoint auth config not found.\", 400)\n  }\n  if (!isOAuth2ClientCredentialsAuthConfig(authConfig)) {\n    throw new HTTPError(\n      \"SharePoint requires an OAuth2 client credentials auth config.\",\n      400\n    )\n  }\n  if (!authConfig.url || !authConfig.clientId) {\n    throw new HTTPError(\n      \"OAuth2 auth config is missing token URL or client ID.\",\n      400\n    )\n  }\n  return authConfig\n}\n\nexport const getSharePointBearerToken = async (\n  datasourceId: string,\n  authConfigId: string\n): Promise<string> => {\n  const connection = await readConnection(datasourceId, authConfigId)","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts#L160-L196","documentation":"Error \"SharePoint requires an OAuth2 client credentials auth config.\" thrown in Budibase/budibase.","triggerScenarios":"Thrown at packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts:178 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":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}