{"record":{"id":"0f0bdfa74da68d48","repo":"RocketChat/Rocket.Chat","slug":"not-authorized-0f0bdf","errorCode":"not_authorized","errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts","lineNumber":18,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Meteor } from 'meteor/meteor';\n\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\nimport { clearIntegrationHistoryMethod } from '../../lib/integrations/functions/clearIntegrationHistory';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tclearIntegrationHistory(integrationId: string): Promise<boolean>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync clearIntegrationHistory(integrationId) {\n\t\tmethodDeprecationLogger.method('clearIntegrationHistory', '9.0.0', '/v1/integrations.clearHistory');\n\t\tif (!this.userId) {\n\t\t\tthrow new Meteor.Error('not_authorized', 'Unauthorized', { method: 'clearIntegrationHistory' });\n\t\t}\n\t\tawait clearIntegrationHistoryMethod(this.userId, integrationId);\n\t\treturn true;\n\t},\n});\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/integrations/clearIntegrationHistory.ts#L1-L24","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nMeteor.call('clearIntegrationHistory', integrationId, cb); // not_authorized\n\n// after\nif (!Meteor.userId()) { await relogin(); }\nMeteor.call('clearIntegrationHistory', integrationId, cb);\n// or: POST /v1/integrations.clearHistory { integrationId } with auth headers","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) { await relogin(); }\nMeteor.call('clearIntegrationHistory', integrationId, cb);","typeGuard":null,"tryCatchPattern":"Meteor.call('clearIntegrationHistory', integrationId, (err, ok) => {\n  if (err && (err as Meteor.Error).error === 'not_authorized') {\n    // unauthenticated DDP call — re-login and retry, or move to REST\n  }\n});","preventionTips":["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"],"tags":["rocket-chat","authentication","integrations","meteor-methods"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}