惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
博客园 - 叶小钗
爱范儿
爱范儿
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
T
Tailwind CSS Blog
博客园 - 司徒正美
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
From Gmail OAuth hell to one-line agent identity
Qasim Muhamm · 2026-05-05 · via DEV Community

I tried to give an AI agent its own email account three different ways. The first two took most of an afternoon. The third took 28 seconds. This is the migration story.

Attempt 1: dedicated Gmail account

The first instinct: just create a Gmail. Free, familiar, works everywhere.

Forty-five minutes in:

  • Created a new Google account with a phone number Google would accept (the agent does not have a phone)
  • Configured 2FA, generated an app password (Gmail no longer accepts plain passwords for IMAP)
  • Hit the "less secure apps" wall, learned it has been retired
  • Set up OAuth 2.0 client in Google Cloud Console
  • Configured the consent screen, reviewed scopes, marked it "Internal"
  • Realised Internal apps cannot be created on free Workspace, so I made it External
  • Filled in the privacy policy URL, terms URL, app domain — for an agent

I had not sent a single message yet.

Attempt 2: shared Gmail with a +alias

"Just use me+agent@gmail.com" is the popular shortcut. It works for receiving (Gmail routes + aliases to the same inbox), but:

  • The "From" address on outbound is still the parent account
  • The agent's mail mixes with mine, so my filters break
  • Compromise of the agent's credentials = compromise of my personal mail
  • Audit logs cannot tell us apart

Two hours later I gave up on this path. The mixing problem is fatal once you have more than one agent.

Attempt 3: nylas agent account create

$ nylas agent account create coder@yourapp.nylas.email

✓ Agent account created successfully!

  Email:      coder@yourapp.nylas.email
  Provider:   nylas
  Status:     valid

Enter fullscreen mode Exit fullscreen mode

Twenty-eight seconds wall-clock. No OAuth, no Workspace seat, no shared mailbox.

What is happening under the hood

Three things, in this order:

  1. The CLI auto-creates the nylas connector on your application if it does not exist. This is a one-time, idempotent setup.
  2. It provisions a managed mailbox under your application's *.nylas.email zone. The mailbox lives entirely on Nylas — no Gmail, no Workspace, no third-party IMAP.
  3. It stores the new grant locally so subsequent CLI commands resolve it without an explicit --grant.

The grant is provider=nylas, which means: no OAuth handshake, no token refresh, no client-secret rotation. The identity is managed end-to-end.

Side-by-side comparison

Step Gmail OAuth Agent account
Create the identity ~5 min (account, 2FA, app password) One command
Configure OAuth client ~12 min (Cloud Console, scopes, consent) Not applicable
Wire up auth in your app ~10 min (refresh token plumbing) One nylas auth config
Setup time total ~45 min ~30 sec
Per-month cost Workspace seat $6 None
Token refresh Yours to manage Not applicable
Multi-provider reach Gmail only Gmail, Outlook, Exchange, Yahoo, iCloud, IMAP, agent

Migrating an existing agent

If you have already wired up an agent to a Gmail account, the migration is mechanical:

# 1. Provision the agent's new identity
nylas agent account create coder@yourapp.nylas.email

# 2. Optional: enable IMAP/SMTP (if your agent uses a stock library)
nylas agent account update coder@yourapp.nylas.email \
  --app-password 'ValidAgentPass123ABC!'

# 3. Send a test
nylas email send --to you@example.com \
  --subject "test from new agent identity" \
  --body "Hi from the managed inbox."

# 4. Update the agent's prompt / config to use the new address

Enter fullscreen mode Exit fullscreen mode

That is the whole migration. The hardest part is finding everywhere the old address is hard-coded.

What I'd warn future-me about

Three lessons from the misadventure:

  1. Phone number requirement: Gmail's signup will demand a phone for verification. Agents do not have phones. Burn an OTP-friendly number and accept Google may flag the account later.
  2. OAuth refresh tokens expire: a Gmail OAuth refresh token is not infinite. Tokens for unverified Cloud apps expire after 7 days; production verification is its own multi-week project.
  3. Per-seat costs scale: if your team runs 5 agents, that is 5 Workspace seats at $6 each = $30/mo just to give them mail.

When Gmail still wins

Be honest about the trade. If the agent must read or send from an existing inbox at @yourcompany.com (your real domain), and your company is on Workspace, you do not want a separate Nylas address. In that case, OAuth Gmail and pay the setup cost. The agent identity model is for new agent inboxes, not for migrating your CEO's mailbox.

For everything else — testing, signup automation, agent-to-agent messaging, ephemeral inboxes, managed bots — the agent account wins on every dimension I can measure.

Next steps