# Building Secure AI Agents with Microsoft Agent Framework and Auth0: Sending Email with Token Vault

[Auth0](https://yomu.fyi/company/auth0) · Andrea Chiarelli · Aug 19, 2026

**Type:** Tutorial

## Summary

An expense-reviewing AI agent required manual manager intervention to email employees about missing report data such as amounts, merchants, or justifications. To automate follow-ups safely, the agent uses Auth0 Token Vault to acquire and refresh Google OAuth tokens without storing credentials in the application database. The implementation configures Auth0 with offline access, My Account API permissions, and multi-resource refresh tokens to handle silent token retrieval across user sessions. Rather than exposing Gmail credentials to the underlying language model, the agent executes email actions via an internal backend endpoint that retrieves a short-lived access token, sends the email, and immediately discards the token.

## Context

An AI agent capable of reviewing expense reports could identify missing details but could not act on that information, forcing managers to manually compose and send follow-up emails from their own email clients.

## Approach / What changed

The system integrates Auth0 Token Vault to securely manage external Google OAuth access and refresh tokens. Auth0 is configured with offline access and the My Account API alongside Multi-Resource Refresh Token policies to permit silent token exchange. When the agent triggers email sending, it calls an authenticated server-side API endpoint that fetches an on-demand, short-lived Gmail access token from Token Vault, dispatches the email via the Gmail API, and immediately discards the token without exposing it to the language model.

## Takeaways

- Storing Google OAuth credentials in Auth0 Token Vault eliminates the need to store third-party access and refresh tokens directly in the application database.
- Tokens are kept hidden from the language model by managing execution inside backend endpoints or constructor-injected tools rather than passing tokens as tool arguments or responses.
- Enabling Multi-Resource Refresh Token policies and offline access allows the application server to silently exchange the user's login session for fresh My Account API or Gmail tokens without re-prompting.

**Tags:** [Authentication](https://yomu.fyi/topic/authentication), [LLMs](https://yomu.fyi/topic/llm)

[Read original post](https://auth0.com/blog/building-secure-ai-agents-microsoft-agent-framework-auth0-part-3-sending-email-with-token-vault)
