{"record":{"id":"0643586b3dfcd09b","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-064358","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/deleteOAuthApp.ts","lineNumber":38,"sourceCode":"\n\tconst application = await OAuthApps.findOneAndDeleteById(applicationId, { projection: { clientId: 1 } });\n\tif (!application) {\n\t\tthrow new Meteor.Error('error-application-not-found', 'Application not found', {\n\t\t\tmethod: 'deleteOAuthApp',\n\t\t});\n\t}\n\n\tawait OAuthAccessTokens.deleteMany({ clientId: application.clientId });\n\tawait OAuthAuthCodes.deleteMany({ clientId: application.clientId });\n\n\treturn true;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync deleteOAuthApp(applicationId) {\n\t\tmethodDeprecationLogger.method('deleteOAuthApp', '9.0.0', '/v1/oauth-apps.delete');\n\t\tif (!this.userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'deleteOAuthApp' });\n\t\t}\n\n\t\treturn deleteOAuthApp(this.userId, applicationId);\n\t},\n});\n","sourceCodeStart":20,"sourceCodeEnd":44,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/auth/deleteOAuthApp.ts#L20-L44","documentation":"The deleteOAuthApp Meteor method wrapper throws 'error-invalid-user' when this.userId is falsy — the DDP connection is not authenticated. The method is deprecated since 9.0.0 in favor of DELETE /api/v1/oauth-apps.delete, which takes explicit authentication.","triggerScenarios":"Calling Meteor.call('deleteOAuthApp', applicationId) on a logged-out connection or with an expired resume token.","commonSituations":"Session expired while the OAuth apps admin page sat open; scripts calling the method without login.","solutions":["Log in before calling the method","Migrate to DELETE /api/v1/oauth-apps.delete with an authenticated token","For scripts, authenticate first (POST /api/v1/login or a personal access token)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // re-login before deleting OAuth apps\n}\nawait Meteor.callAsync('deleteOAuthApp', applicationId);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('deleteOAuthApp', applicationId);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-user') {\n    // session expired: re-login, then retry once\n  }\n}","preventionTips":["Check Meteor.userId() before admin method calls","Migrate to the REST endpoint, which fails with a clear 401 instead","Refresh the OAuth apps list after re-login to avoid stale state"],"tags":["authentication","oauth","meteor-methods","deprecated"],"backgroundTag":"not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}