Deleting Google Credentials
Relevant source files
The following files were used as context for generating this wiki page:The "Deleting Google Credentials" feature provides an automated mechanism to delete a Cursor user account that was originally authenticated via Google OAuth. This process is handled by the delete_cursor_google.py script, which uses browser automation to navigate the Cursor website and perform the necessary actions for account deletion. This functionality is crucial for users who wish to reset their account status or remove their data from the Cursor platform.
The core of this feature is the CursorGoogleAccountDeleter class, which inherits browser setup and profile management capabilities from the OAuthHandler base class. The script is designed to be robust, employing multiple selectors and fallback mechanisms to accommodate potential changes in the Cursor website's user interface. All user-facing messages are internationalized, drawing strings from JSON locale files.
Architecture and Core Components
The feature is built upon a simple class hierarchy, leveraging a shared OAuthHandler for common browser automation tasks.
This diagram illustrates the inheritance relationship between the main classes involved.
Key Components
| Component | File | Description |
|---|---|---|
main() | delete_cursor_google.py | The main entry point. It handles user confirmation and orchestrates the deletion process by calling CursorGoogleAccountDeleter. |
CursorGoogleAccountDeleter | delete_cursor_google.py | A class that encapsulates the entire account deletion workflow, from logging in to final deletion confirmation. |
delete_google_account() | delete_cursor_google.py | The primary method within CursorGoogleAccountDeleter that executes the step-by-step browser automation for account deletion. |
OAuthHandler | oauth_auth.py | A base class providing foundational browser automation logic, including browser setup, profile selection, and process management. |
setup_browser() | oauth_auth.py | A method in OAuthHandler responsible for killing existing browser processes, allowing profile selection, and launching a configured DrissionPage browser instance. |
locales/en.json | locales/en.json | A JSON file containing English language strings for the user interface, used by the translator object. |
Sources: delete_cursor_google.py:20-326, 410-442, oauth_auth.py:24-301, locales/en.json:442-486
Deletion Process Flow
The account deletion process is a linear sequence of browser automation steps. The script logs into the user's Cursor account via Google OAuth, navigates to the settings page, and proceeds through the deletion confirmation dialogs.
The following flowchart shows the high-level logic of the delete_google_account method.
Sources: delete_cursor_google.py:27-326
1. Initialization and Confirmation
The process begins in the main function.
- A
CursorGoogleAccountDeleterinstance is created. - The user is shown a warning and prompted for confirmation to proceed with the permanent deletion.
- If the user confirms, the
delete_google_accountmethod is called.
Sources: delete_cursor_google.py:410-428
2. Browser Setup and Authentication
The script first needs to log in to the user's account.
setup_browser()from theOAuthHandlerparent class is called. This handles killing old browser processes and launching a new browser instance with a user-selected profile.- The browser navigates to
https://authenticator.cursor.sh/sign-up. - It finds and clicks the Google OAuth login button using a list of XPath selectors for robustness.
- The script then enters a waiting loop (up to 120 seconds) for the user to complete the authentication with Google. If it detects the Google account selection page, it can show a JavaScript
alertto prompt the user for action.
The sequence diagram below details the interactions during the authentication phase.
3. Navigating to Account Settings
Once authenticated, the script ensures it is on the correct page to begin the deletion.
- It checks the current URL. If it's already on the settings page (
/settings), it proceeds. - If it's on another Cursor page (like
/dashboard), it explicitly navigates tohttps://www.cursor.com/settings. - As a fallback, if the redirect after login failed, it attempts to navigate directly to the settings page.
- It then tries to find the user's email on the page to confirm a successful login.
Sources: delete_cursor_google.py:98-131
4. Interacting with the Settings Page
The script automates clicks to reveal the deletion option.
- Click "Advanced" Tab: It first tries to click the "Advanced" tab using a direct JavaScript
querySelector. If that fails, it falls back to navigating directly to the advanced tab's URL:https://www.cursor.com/settings?tab=advanced. - Click "Delete Account": It searches for the "Delete Account" button using a list of potential XPath selectors and clicks it to open the confirmation modal.
Sources: delete_cursor_google.py:133-200
5. Final Confirmation and Deletion
The final steps involve interacting with the confirmation modal dialog.
- Check for Input Requirement: The script runs a JavaScript snippet to check if the final
DELETEbutton is already enabled. If so, it assumes typing "Delete" is not required. - Type "Delete": If required, it finds the confirmation input field and types the word "Delete". It uses a JS-based fallback to set the input value if standard methods fail.
- Click Final "DELETE" Button: The script uses a robust JavaScript function to find and click the final confirmation button. The JS searches for a button with the text
DELETEorDelete. If that fails, it heuristically clicks the right-most button in the modal, which is often the confirmation button. A final fallback to XPath selectors is also present.
Sources: delete_cursor_google.py:205-314
User Interface and Internationalization
The script provides continuous feedback to the user in the console.
- Colored Output: It uses the
coloramalibrary to display messages in different colors (e.g., green for success, red for error). - Emojis: A dictionary of emojis is used to visually denote the status of different operations.
- Internationalization (i18n): All user-facing strings are retrieved via a
translatorobject. This allows the script's output to be translated into different languages by providing the appropriate locale file. The English strings are defined inlocales/en.json.
Sources: delete_cursor_google.py:9-17, 25
The table below shows the keys and default English text used during the account deletion process.
| Key | English Text (locales/en.json) |
|---|---|
account_delete.title | Cursor Google Account Deletion Tool |
account_delete.warning | WARNING: This will permanently delete your Cursor account. This action cannot be undone. |
account_delete.confirm_prompt | Are you sure you want to proceed? (y/N): |
account_delete.cancelled | Account deletion cancelled. |
account_delete.starting_process | Starting account deletion process... |
account_delete.logging_in | Logging in with Google... |
account_delete.waiting_for_auth | Waiting for Google authentication... |
account_delete.login_successful | Login successful |
account_delete.navigating_to_settings | Navigating to settings page... |
account_delete.advanced_tab_clicked | Clicked on Advanced tab |
account_delete.delete_button_clicked | Clicked on Delete Account button |
account_delete.typed_delete | Typed "Delete" in confirmation box |
account_delete.success | Your Cursor account has been successfully deleted! |
account_delete.failed | Account deletion process failed or was cancelled. |
account_delete.error | Error during account deletion: {error} |
Sources: locales/en.json:442-486
Error Handling and Cleanup
The script is designed to handle failures gracefully.
- Multiple Selectors: For each UI element, a list of XPath or CSS selectors is used. The script iterates through them until one succeeds, making it resilient to minor changes in the website's HTML structure.
- JavaScript Fallbacks: For critical actions like typing text and clicking buttons, JavaScript snippets are used as a fallback if standard
DrissionPagemethods fail. - Timeouts: The script uses explicit waits and timeouts (e.g., 120 seconds for authentication) to avoid getting stuck indefinitely.
try...except...finally: The main deletion logic is wrapped in atry...finallyblock. Thefinallyclause ensures thatself.browser.quit()is always called, closing the browser and cleaning up resources, regardless of whether the process succeeded or failed.
Sources: delete_cursor_google.py:41-52, 181-192, 230-250, 264-314, 316-325
Conclusion
The "Deleting Google Credentials" feature is a powerful automation script that simplifies the removal of a Google-linked Cursor account. By inheriting from a common OAuthHandler and using the DrissionPage library, it methodically performs a sequence of browser interactions that would otherwise be manual. Its robustness is enhanced through multiple element selectors, JavaScript fallbacks, and comprehensive error handling. The use of a translator for UI strings also makes it adaptable for a global user base. While effective, its reliance on web scraping means it may require maintenance if the Cursor website undergoes significant structural changes.