---
title: "Building Secure AI Agents with Microsoft Agent Framework and Auth0 Token Vault"
url: https://daily.dev/posts/building-secure-ai-agents-with-microsoft-agent-framework-and-auth0-token-vault-ccjnfxrsp
source_url: https://auth0.com/blog/building-secure-ai-agents-microsoft-agent-framework-auth0-part-3-sending-email-with-token-vault
type: article
source: "Auth0"
published: 2026-08-19T14:36:54.139Z
updated: 2026-08-19T15:06:21.184Z
tags: ["ai-agents", "authentication", ".net", "oauth", "auth0"]
reading_time: 26
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[Auth0](https://daily.dev/sources/auth0)** · 26 min read · 1 upvotes · 0 comments

## Summary

A hands-on walkthrough shows how to add a SendMissingDataEmail tool to a .NET expense-approval AI agent built with Microsoft Agent Framework, using Auth0 Token Vault to securely manage Gmail OAuth tokens. Rather than storing Google access/refresh tokens in the application, Token Vault issues short-lived tokens on demand, and constructor injection keeps the Gmail token invisible to the LLM and its tool schema. The guide covers configuring the Google connection with Token Vault, enabling the My Account API and Multi-Resource Refresh Tokens for a separate Connected Accounts linking flow, updating Blazor components to track link status, building an EmailService, and wiring a backend endpoint that fetches a fresh token per request and immediately discards it. Part three of a series that will add CIBA-based push approval next.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://auth0.com/blog/building-secure-ai-agents-microsoft-agent-framework-auth0-part-3-sending-email-with-token-vault>

## Questions this post answers

### How do I let an AI agent send emails through Gmail without exposing OAuth tokens to the LLM?

Use a credential vault like Auth0 Token Vault to store Google access and refresh tokens outside the application, and fetch a short-lived access token only inside a backend endpoint right before calling the Gmail API, then discard it immediately. Inject the token via constructor injection into the tool class rather than passing it as a tool argument, so it never appears in the model's schema or responses.

_Developers wiring OAuth into agent tools can compare token-vault patterns like this on daily.dev._

### Why does a Blazor Server app need to set BaseAddress explicitly on HttpClient when calling its own API endpoints?

A plain HttpClient in a Blazor Server circuit has no base address of its own, unlike a WebAssembly client that resolves relative URLs against the page it runs in. Without explicitly setting BaseAddress using NavigationManager.BaseUri, a relative request such as /api/send-missing-data-email throws an InvalidOperationException before leaving the process.

_Blazor developers debugging HttpClient errors can find similar gotchas on daily.dev._

### How do you link a Google account for API access after a user already logged in with a different identity provider?

Use Auth0's Connected Accounts flow against the My Account API, a three-step handshake separate from login: initiate the connection to get a ConnectUri and ticket, redirect the browser so the user consents on Google, then complete the connection using a single-use connect_code returned in the URL fragment after Google redirects back. This requires enabling the My Account API, granting the create:me:connected_accounts scope, and configuring a Multi-Resource Refresh Token policy.

_Engineers building secondary account-linking flows can dig deeper into OAuth patterns on daily.dev._

## Similar posts on daily.dev

- [Microsoft Agent Framework and Python: Use the Auth0 Token Vault to call Third-Party APIs](https://daily.dev/posts/microsoft-agent-framework-and-python-use-the-auth0-token-vault-to-call-third-party-apis-htp7vvxr6) · Auth0 · 0 upvotes · 0 comments
- [Secure Your AI: Stop Managing API Keys by Hand](https://daily.dev/posts/secure-your-ai-stop-managing-api-keys-by-hand-iv0c4o7y4) · Auth0 · 1 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#authentication](https://daily.dev/tags/authentication), [#.net](https://daily.dev/tags/.net), [#oauth](https://daily.dev/tags/oauth), [#auth0](https://daily.dev/tags/auth0)

[View this post on daily.dev](https://daily.dev/posts/building-secure-ai-agents-with-microsoft-agent-framework-and-auth0-token-vault-ccjnfxrsp)
