louislam/uptime-kuma · error · Error
The oauth config is invalid. ${e.message}
Error message
The oauth config is invalid. ${e.message} What it means
Thrown by getOauth2AuthHeader when auth_method === 'oauth2-cc' and the OAuth2 client-credentials token request fails for any reason. The original error message is appended so the root cause (bad URL, bad credentials, network) is visible. This fires before the HTTP measurement is even created, so the heartbeat fails at auth setup.
Source
Thrown at server/monitor-types/globalping.js:537
monitor.oauth_token_url,
monitor.oauth_client_id,
monitor.oauth_client_secret,
monitor.oauth_scopes,
monitor.oauth_audience,
monitor.oauth_auth_method
);
log.debug(
"monitor",
`[${monitor.name}] Obtained oauth access-token. Expires at ${new Date(oAuthAccessToken.expires_at * 1000)}`
);
monitor.oauthAccessToken = oAuthAccessToken;
}
return {
Authorization: monitor.oauthAccessToken.token_type + " " + monitor.oauthAccessToken.access_token,
};
} catch (e) {
throw new Error("The oauth config is invalid. " + e.message);
}
}
/**
* Generates the basic authentication header for a monitor if it is enabled.
* @param {object} monitor - The monitor object.
* @returns {object} The basic authentication header.
*/
getBasicAuthHeader(monitor) {
if (monitor.auth_method !== "basic") {
return {};
}
return {
Authorization: "Basic " + encodeBase64(monitor.basic_auth_user, monitor.basic_auth_pass),
};
}
View on GitHub (pinned to 6b5ea01557)
Solutions
- Verify oauth_token_url is the correct token endpoint for your IdP
- Confirm oauth_client_id and oauth_client_secret are current and not revoked
- Check that oauth_scopes and oauth_audience match what the IdP allows
- Ensure oauth_auth_method (client_secret_basic vs post) matches the IdP's registered client config
Example fix
// before: wrong token endpoint auth method for the registered client monitor.oauth_auth_method = "client_secret_post"; // after: match the IdP registration monitor.oauth_auth_method = "client_secret_basic";
Defensive patterns
Strategy: validation
Validate before calling
// Validate OAuth2 client-credentials config before the HTTP check
if (monitor.auth_method === "oauth2-cc") {
for (const f of ["oauth_token_url", "oauth_client_id", "oauth_client_secret"]) {
if (!monitor[f]) throw new Error("Missing OAuth2 field: " + f);
}
try { new URL(monitor.oauth_token_url); } catch {
throw new Error("oauth_token_url is not a valid URL");
}
} Try / catch
// Test the token fetch in isolation so the real error surfaces
try {
return { Authorization: monitor.oauthAccessToken.token_type + " " + monitor.oauthAccessToken.access_token };
} catch (e) {
throw new Error("The oauth config is invalid. " + e.message);
} Prevention
- Keep client secrets in a secret store and rotate before expiry
- Confirm the token endpoint URL and auth method match the IdP client registration
- Verify scopes/audience are permitted by the IdP
When it happens
Trigger: monitor.auth_method === 'oauth2-cc' and getOidcTokenClientCredentials rejects: wrong oauth_token_url, invalid/missing oauth_client_id or oauth_client_secret, unsupported oauth_auth_method, bad/expired scopes, or a network failure reaching the IdP.
Common situations: OAuth client secret rotated but not updated in the monitor, token URL mistyped or not reachable, wrong grant/scope for the IdP, or the IdP rejecting the configured token endpoint auth method.
Related errors
- The oauth config is invalid. ${e.message}
- Status code ${result.statusCode} not accepted. Output: ${res
- No record matched.
- ${heartbeat.msg}, but keyword is ${keywordFound ? "present"
- JSON query does not pass (comparing ${response} ${monitor.js
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/88aebb4717b82530.
Report an issue: GitHub.