Budibase/budibase · error · HTTPError

OAuth2 auth config is missing token URL or client ID.

Error message

OAuth2 auth config is missing token URL or client ID.

What it means

The auth config is an OAuth2 client-credentials config, but its token endpoint URL (authConfig.url) or clientId is empty. Both are required to obtain a bearer token from Microsoft Entra ID, so readConnection throws a 400 HTTPError before attempting any network call.

Source

Thrown at packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts:184

    datasource = await sdk.datasources.get(datasourceId)
  } catch {
    throw new HTTPError("SharePoint auth config not found.", 400)
  }
  const authConfigs = datasource.config?.authConfigs as
    | OAuth2RestAuthConfigWithTokenCache[]
    | undefined
  const authConfig = authConfigs?.find(config => config._id === authConfigId)
  if (!authConfig) {
    throw new HTTPError("SharePoint auth config not found.", 400)
  }
  if (!isOAuth2ClientCredentialsAuthConfig(authConfig)) {
    throw new HTTPError(
      "SharePoint requires an OAuth2 client credentials auth config.",
      400
    )
  }
  if (!authConfig.url || !authConfig.clientId) {
    throw new HTTPError(
      "OAuth2 auth config is missing token URL or client ID.",
      400
    )
  }
  return authConfig
}

export const getSharePointBearerToken = async (
  datasourceId: string,
  authConfigId: string
): Promise<string> => {
  const connection = await readConnection(datasourceId, authConfigId)
  return sdk.oauth2.getTokenFromConfig(`${datasourceId}:${authConfigId}`, {
    url: connection.url,
    clientId: connection.clientId,
    clientSecret: connection.clientSecret,
    method: connection.method,
    grantType: connection.grantType,

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Set authConfig.url to the Microsoft Entra token endpoint for your tenant.
  2. Set authConfig.clientId to the application (client) ID of your Entra app registration.
  3. Re-save the datasource auth config and verify both fields persist before retrying.

Example fix

// before
{ type: "oauth2", grantType: "client_credentials", clientId: "" }
// after
{ type: "oauth2", grantType: "client_credentials", url: "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token", clientId: "<app-client-id>", clientSecret: "..." }
Defensive patterns

Strategy: validation

Validate before calling

if (!authConfig.url || !authConfig.clientId) {
  throw new Error("OAuth2 auth config requires a token URL and client ID")
}
await fetchSharePointSitesByDatasourceAuthConfig(datasourceId, authConfigId)

Type guard

const hasOAuth2ConnectionFields = (
  c: OAuth2RestAuthConfig
): c is OAuth2RestAuthConfig & { url: string; clientId: string } =>
  typeof c.url === "string" && c.url.length > 0 &&
  typeof c.clientId === "string" && c.clientId.length > 0

Prevention

When it happens

Trigger: Saving a client-credentials auth config without the token URL or without a client ID, then using it for SharePoint knowledge source operations.

Common situations: Incomplete datasource setup wizard; user left the token URL field blank (correct Entra endpoint is https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token); client ID omitted; config migrated and fields lost.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/6179f2093fd0f276. Report an issue: GitHub.