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
- Set authConfig.url to the Microsoft Entra token endpoint for your tenant.
- Set authConfig.clientId to the application (client) ID of your Entra app registration.
- 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
- Require url and clientId fields when saving a client-credentials auth config in the UI.
- Use the full Entra v2.0 token endpoint URL including tenant id.
- Re-validate stored auth configs after migrations or imports.
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
- SharePoint auth config not found.
- Error getting account by email ${email}
- datasourceId and authConfigId are required
- siteId is required
- driveId is required with parentItemId
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/6179f2093fd0f276.
Report an issue: GitHub.