Learn how Auth for GenAI enables AI agents to call other’s APIs on the user’s behalf.
Create an Auth0 Account and a Dev Tenant
Create an Auth0 Application
Regular Web
http://localhost:3000/auth/callback
http://localhost:3000
Enable Token Exchange Grant
Configure Google Social Connection
OpenAI Platform
@auth0/ai-langchain
: Auth0 AI SDK for LangChain built for GenAI applications powered by LangChain.@langchain/langgraph
: For building stateful, multi-actor applications with LLMs.langchain
: The LangChain library.@langchain/core
: LangChain core libraries.@langchain/openai
: OpenAI provider for LangChain.@langchain/community
: LangChain community integrations.langgraph-nextjs-api-passthrough
: API passthrough for LangGraph..env.example
file to .env.local
and update the variables with your Auth0 credentials. You can find your Auth0 domain, client ID, and client secret in the application you created in the Auth0 Dashboard.connection
: pass in the name of the connection you want the user to sign up for/log into.scopes
: pass in the scopes for the service you want to get access to.src/lib/auth0-ai.ts
and instantiate a new Auth0 AI SDK client:/src/lib/auth0.ts
file with the following code:/src/app/api/chat/[..._path]/route.ts
file with the following code. The refreshToken
will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get Google access tokens from the server.GmailSearch
from the @langchain/community
tools. This tool will use the access token provided by Token Vault to query for emails.src/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler.tsx
, with the following code:src/components/chat-window.tsx
file to include the FederatedConnectionInterruptHandler
component:npm run all:dev
. Then, navigate to http://localhost:3000
.