swit-oauth-logout
Log out from Swit OAuth authentication and clear stored tokens to enable re-authentication.
Instructions
Logout from OAuth authentication and delete stored tokens. Use when re-authentication is required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/oauth.handlers.ts:47-60 (handler)The handleOAuthLogout function is the main handler logic for 'swit-oauth-logout'. It checks if OAuthWebServer is available, calls oauthWebServer.getOAuthManager().logout() to clear tokens, and returns a success message.
export const handleOAuthLogout = async (oauthWebServer: OAuthWebServer | null) => { if (!oauthWebServer) { return { error: 'OAuth web server is not available. Cannot perform logout.', }; } oauthWebServer.getOAuthManager().logout(); return { message: 'OAuth logout completed successfully.', note: 'Cached tokens have been cleared. Use swit-oauth-start to re-authenticate.', }; }; - src/handlers/oauth.handlers.ts:62-66 (handler)The oauthHandlers object maps 'swit-oauth-logout' to a lambda that invokes handleOAuthLogout(oauthWebServer). This is where the tool name is wired to its handler function.
export const oauthHandlers = (oauthWebServer: OAuthWebServer | null) => ({ 'swit-oauth-status': () => handleOAuthStatus(oauthWebServer), 'swit-oauth-start': () => handleOAuthStart(oauthWebServer), 'swit-oauth-logout': () => handleOAuthLogout(oauthWebServer), }); - src/tools/oauth.tools.ts:17-21 (registration)Tool registration for 'swit-oauth-logout' defining its name, description ('Logout from OAuth authentication and delete stored tokens...'), and inputSchema (empty Zod object).
{ name: 'swit-oauth-logout', description: 'Logout from OAuth authentication and delete stored tokens. Use when re-authentication is required.', inputSchema: zodToJsonSchema(EmptySchema), }, - src/oauth-manager.ts:131-135 (helper)The OAuthManager.logout() method called by the handler. It sets tokenInfo to null and clears the token cache via tokenCache.clear().
logout(): void { this.tokenInfo = null; this.tokenCache.clear(); console.error('OAuth logout completed'); } - src/token-cache.ts:31-35 (helper)The TokenCache.clear() method used during logout to delete the cached token file from disk.
clear(): void { if (this.exists()) { fs.unlinkSync(this.filePath); } }