Automated Activation of Your Google Workspace Accounts [Free Version]
Setup Accounts and Accept the Terms to Create a Better User Experience
I like to improve the user and onboarding experience
by ensuring every new account is activated. An activated account means the user does not need to accept the terms and conditions.
When I began this process in 2019, I was able to achieve a 95% remote/self-guided onboarding rate.
That means about 5% of users need additional support, or need to meet in person.
If you onboard 200-300 people a year this adds up to a massive time-savings.
The free version of this tutorial has one email address and password that is activated. You could easily modify this to use an array.
However, the paid version of this script uses a CSV file which allows you to automate all your activations unattended. If you want the power version, please do a paid subscription. Access the Paid Version Here.
Remember, this SubStack has a W-9. You can use the content as a service or as a professional development reimbursement. All you need to do is comment to request the W-9 or a more formal receipt.
Notice: This script is Python Based. If you are not familiar with using Python, this might be difficult (but never impossible :).
Overview
This script automates the Google login process by:
Opening a Chrome browser.
Navigating to the Google login page (https://accounts.google.com/).
Entering an email address and password.
Handling optional prompts (like an "I understand" button for EULA).
Saving a screenshot for debugging.
Allowing manual intervention for CAPTCHAs or recovery prompts.
Gracefully closing the browser.
The script uses Selenium's WebDriver with Chrome, explicit waits for reliable element detection, and basic error handling. I am not explaining how to install Selenium. If you are new to Selenium, take a moment to install and test it.
https://www.geeksforgeeks.org/selenium-python-introduction-and-installation/
Dependencies
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import traceback
import time
import os
Ensure all these are installed before you run the script.
# === Import Required Modules ===
# Selenium controls the browser
from selenium import webdriver
from selenium.webdriver.common.by import By # For locating elements
from selenium.webdriver.chrome.service import Service # For defining the ChromeDriver path
from selenium.webdriver.chrome.options import Options # For setting up Chrome options
from selenium.webdriver.support.ui import WebDriverWait # Wait until a condition is true
from selenium.webdriver.support import expected_conditions as EC # Define expected conditions
import traceback # For clean error stack traces
import time # For manual pauses (not ideal for production automation)
import os # For handling file paths
# === Configuration Section ===
email = "youremail@yourdomain.org" # Replace with actual email
password = "YourPassword20279!" # Replace with actual password (use env vars in production)
chrome_driver_path = "/usr/bin/chromedriver" # Adjust this if your driver is elsewhere
debug_screenshot = "login_debug.png" # File name for debug screenshot if something goes wrong
# === Set Chrome Browser Options ===
options = Options()
options.add_argument("--start-maximized") # Launch browser in full-screen mode
options.add_argument("--disable-infobars") # Remove the "Chrome is being controlled" warning
options.add_argument("--disable-notifications") # Block any pop-up notifications
options.add_argument("--no-sandbox") # For Linux systems running as root (e.g. in containers)
options.add_argument("--disable-dev-shm-usage") # Helps in Docker environments
# options.headless = True # Uncomment to run browser in background with no UI (invisible)
# === Launch Chrome Browser ===
service = Service(chrome_driver_path)
driver = webdriver.Chrome(service=service, options=options)
try:
print("🌐 Navigating to Google login...")
driver.get("https://accounts.google.com/") # Step 1: Load the login page
# === Email Entry ===
print("🔐 Entering email...")
WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.ID, "identifierId")) # Wait for the email field
).send_keys(email) # Type the email
driver.find_element(By.ID, "identifierNext").click() # Click the "Next" button
time.sleep(2) # Wait briefly for password page to load
# === Debug Info Capture ===
print("📸 Capturing screen for debug...")
driver.save_screenshot(debug_screenshot) # Screenshot in case of failure
print(f"📷 Screenshot saved to {os.path.abspath(debug_screenshot)}")
print("🔎 Page Title:", driver.title) # Print current page title (debug info)
print("🔗 URL:", driver.current_url) # Print current URL (debug info)
# === Password Entry ===
print("🔐 Waiting for password field...")
password_field = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.NAME, "Passwd")) # Wait for password input field
)
password_field.send_keys(password) # Type in the password
driver.find_element(By.ID, "passwordNext").click() # Submit password
# === Handle Extra Prompt (e.g., Terms of Service) ===
try:
print("👉 Checking for 'I understand' button...")
understand_btn = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, "confirm")) # Some orgs show a confirmation dialog
)
understand_btn.click() # Click the button if it appears
print("👍 'I understand' clicked.")
except:
print("ℹ️ No 'I understand' button found — continuing.") # Not always shown
# === Final Step: Wait for Manual Completion (if needed) ===
print("✅ Login submitted. Handle any remaining prompts manually (CAPTCHA, recovery, etc.)")
time.sleep(30) # Allow time to manually complete any extra steps like CAPTCHA
# === Error Handling ===
except Exception:
print("❌ Error during login flow:")
traceback.print_exc() # Print full error stack trace
# === Clean Up ===
finally:
print("🔒 Closing browser...")
driver.quit() # Close browser regardless of success or failure