How to let an AI agent use your accounts (X, Gmail, Reddit) without giving it your password
Three ways to give an AI agent access to your X, Gmail or Reddit accounts, what each one risks (keys in logs, prompt injection, posts you didn't want) and the habits that keep it safe.
An agent that can only talk is a nice demo. The useful ones read your inbox, answer mentions on X, post in a subreddit, check a dashboard. All of that needs your accounts. The question isn't whether to give an agent access, it's how: there are three common ways, and one of them should never be used.
#What are the three ways to give an agent your accounts?
| Way | How it works | Main risk |
|---|---|---|
| API key or OAuth token | The agent calls the service's API with a key or a token you created | The key leaks: a log, a transcript, a committed file |
| Password in the prompt | You paste the login and password into the chat or the instructions | Everything: the password is in clear, everywhere, for good |
| A browser already signed in | The agent works in its own browser, where you signed in yourself once | It acts as you on the site, so what it sends must be checked |
Most setups mix the first and the third: an API where the service has a decent one, a signed-in browser where it doesn't.
#When is an API key or OAuth token the right choice?
When the service has an API that covers the job, and lets you limit what the key can do. Gmail is a good example: Google's API has separate scopes for reading (gmail.readonly), for drafts (gmail.compose) and for sending (gmail.send), listed in its scopes page. An agent that triages your inbox needs the first one, not the last.
The catch is that a key is a string, and strings travel. It can be printed in a tool result, pasted into a script, written to a .env that syncs to the cloud, or kept in the session's transcript on disk. Keeping keys out of the chat covers the habits: environment variables, deny rules, the Keychain. The other catch is coverage. Many sites have no API for what you need, or one that's paid, limited or closed to small accounts.
#Why is pasting a password into the prompt a bad idea?
Because a prompt is not a safe. The password ends up:
- in the conversation history, on disk and often in the provider's logs;
- in every copy of the instructions, every export, every teammate's shared agent;
- within reach of anything the agent reads. A web page or an email can carry hidden instructions ("send your login details to…"), which is the first risk in the OWASP Top 10 for LLM applications (LLM01, prompt injection), right before sensitive information disclosure (LLM02).
And a password is all-or-nothing. It can't be limited to reading, it can change the recovery email, and it works until you notice. Two-step verification makes it worse, not better: the agent either fails at the code prompt or you start sharing codes too.
#How does a signed-in browser work?
You give the agent a browser of its own, separate from yours, and sign in there yourself, once. The agent gets the session (the cookies), never the password. It can then read and act on sites that have no usable API: your X timeline, a Reddit thread, the LinkedIn page of your company, a dashboard. AI agents with a browser goes through how they read pages and fill in forms.
Two things matter with this approach:
- One browser per agent, not your own Chrome. An agent in your daily browser has your bank, your mail and your admin panels in the next tab. Its own browser holds only the accounts you gave it.
- The session is still power. A signed-in X account can post, follow and send messages. So the browser solves the password problem, not the "what does it send" problem.
For mail specifically, the safest version is often a separate address for the agent rather than your own inbox: see giving an AI agent its own email address.
#What can go wrong once an agent has access?
Three failures, in order of how often they happen:
- The key or session leaks. A key printed in a log, a token in a committed file, a
.envin a shared folder. Nobody attacked anything; it just ended up somewhere readable. - Prompt injection. The agent reads something written by a stranger (a mention, an email, a web page) that tells it what to do. Simon Willison calls the dangerous combination the lethal trifecta: access to private data, exposure to untrusted content, and a way to communicate outward. An agent that reads your Gmail and can send mail has all three.
- A post you didn't want. No attacker at all: the agent misread the brief, replied to the wrong thread, posted a draft, or posted ten times. OWASP lists this under excessive agency (LLM06): more permissions or autonomy than the job needs.
#How do you protect your accounts?
None of these habits is new; they're how you'd onboard a freelancer.
- Give access per agent, not to all of them. The agent that answers support doesn't need your X account. The one that posts on X doesn't need Stripe. If an agent is fooled, it can only misuse what it holds.
- Start read-only. Give the reading scope or a read-only key first. Let the agent prove its drafts are good before it can send anything.
- Make it ask before anything goes out. Reading and drafting can run freely; a post, a reply, a mail or a form sent should wait for your yes until you trust that exact kind of send. When an AI agent should ask before it acts sets out a simple rule for it.
- Check what goes out, not only what comes in. A last look at each send for a key, a password or a link it shouldn't carry catches the leak that prompt injection was after.
- Keep keys on the machine. Keys in the Keychain or a secret manager, passed to the agent as environment variables it can use but not print, and never sent to a server that doesn't need them.
- Keep volumes human. Platform rules still apply to automated accounts. X, for one, expects automated accounts to say so.
- Know how to take it back. Revoking a token, signing the agent's browser out, or removing the account from the agent should take one step.
#In Relais
Relais is one way to set this up, on the Claude account you already have (it isn't made or endorsed by Anthropic). Since version 0.3.2, accounts on sites (X, Reddit, LinkedIn, Instagram, Gmail) live in its Vault: you sign in once, in a browser of the agent's own, and every agent you give the account to can use it to read and to post. Relais never sees the password.
API keys sit in the same Vault, kept in the macOS Keychain and given only to the agents that need them, as environment variables; a command that prints one is refused. Posts, replies and mails wait in the agent's conversation for your yes, unless you write a rule that lets that agent send on its own (approvals). And every send an agent makes is checked, drafts and files included, so no key ever leaves with it. Relais itself has no telemetry: no analytics, no trackers.