{"record":{"id":"bede997d3a39a6f1","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-bede99","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/auth/removeOAuthService.ts","lineNumber":75,"sourceCode":"\n\tconst promises = settingsIds.map((id) => Settings.removeById(id));\n\n\t(await Promise.all(promises)).forEach((value, index) => {\n\t\tif (value?.deletedCount) {\n\t\t\tvoid notifyOnSettingChangedById(settingsIds[index], 'removed');\n\t\t}\n\t});\n};\n\nMeteor.methods<ServerMethods>({\n\tasync removeOAuthService(name) {\n\t\tmethodDeprecationLogger.method('removeOAuthService', '9.0.0', '/v1/settings.removeCustomOAuth');\n\t\tcheck(name, String);\n\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'removeOAuthService',\n\t\t\t});\n\t\t}\n\n\t\tif ((await hasPermissionAsync(userId, 'add-oauth-service')) !== true) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'removeOAuthService' });\n\t\t}\n\n\t\tawait removeCustomOAuthSettings(name);\n\t},\n});\n","sourceCodeStart":57,"sourceCodeEnd":87,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/auth/removeOAuthService.ts#L57-L87","documentation":"The removeOAuthService method wrapper throws 'error-invalid-user' when Meteor.userId() returns null — the DDP connection is not authenticated. Deprecated since 9.0.0 in favor of /v1/settings.removeCustomOAuth.","triggerScenarios":"Calling removeOAuthService(name) while logged out or with an expired/invalidated session token.","commonSituations":"Session dropped while the OAuth settings page was open; scripts calling the method without a login flow.","solutions":["Log in with a valid session before calling removeOAuthService","Migrate to /v1/settings.removeCustomOAuth with an authenticated request","For scripts, authenticate first via REST"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // re-login before removing a custom OAuth service\n}\nawait Meteor.callAsync('removeOAuthService', name);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('removeOAuthService', name);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-user') {\n    // session expired: re-login, then retry\n  }\n}","preventionTips":["Require an authenticated session for destructive settings operations","Use /v1/settings.removeCustomOAuth with explicit auth in scripts"],"tags":["authentication","oauth","settings","meteor-methods","deprecated"],"backgroundTag":"not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}