RocketChat/Rocket.Chat · error · Meteor.Error
not_authorized
not_authorized
Error message
Unauthorized
What it means
clearIntegrationHistory reads `this.userId` from the DDP method invocation and throws not_authorized when it is falsy. Clearing an integration's history requires an authenticated connection; unlike many Rocket.Chat errors this one uses the bare 'not_authorized' code with the method name in the details object.
Source
Thrown at apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts:18
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';
import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';
import { clearIntegrationHistoryMethod } from '../../lib/integrations/functions/clearIntegrationHistory';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
clearIntegrationHistory(integrationId: string): Promise<boolean>;
}
}
Meteor.methods<ServerMethods>({
async clearIntegrationHistory(integrationId) {
methodDeprecationLogger.method('clearIntegrationHistory', '9.0.0', '/v1/integrations.clearHistory');
if (!this.userId) {
throw new Meteor.Error('not_authorized', 'Unauthorized', { method: 'clearIntegrationHistory' });
}
await clearIntegrationHistoryMethod(this.userId, integrationId);
return true;
},
});
View on GitHub (pinned to b2c16d5842)
Solutions
- Ensure an authenticated session (`Meteor.userId()` set) before calling
- Re-login and retry once when this appears
- Migrate to POST /v1/integrations.clearHistory with valid auth headers (the method is deprecated since 9.0.0)
Example fix
// before
Meteor.call('clearIntegrationHistory', integrationId, cb); // not_authorized
// after
if (!Meteor.userId()) { await relogin(); }
Meteor.call('clearIntegrationHistory', integrationId, cb);
// or: POST /v1/integrations.clearHistory { integrationId } with auth headers Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) { await relogin(); }
Meteor.call('clearIntegrationHistory', integrationId, cb); Try / catch
Meteor.call('clearIntegrationHistory', integrationId, (err, ok) => {
if (err && (err as Meteor.Error).error === 'not_authorized') {
// unauthenticated DDP call — re-login and retry, or move to REST
}
}); Prevention
- Bind an authenticated user to every integration-administration call
- Migrate off this deprecated method (9.0.0) to POST /v1/integrations.clearHistory
- Handle token expiry in long-lived admin sessions
When it happens
Trigger: Calling `Meteor.call('clearIntegrationHistory', integrationId)` from a logged-out connection or one whose session expired before the call; server-side invocation lacking a bound user.
Common situations: Integration management screens used after a token expiry; scripts clearing history without login; the method is deprecated in 9.0.0 — clients that migrated to POST /v1/integrations.clearHistory must send X-User-Id/X-Auth-Token or they hit the REST 401 instead.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/0f0bdfa74da68d48.
Report an issue: GitHub.