Learn how Auth for GenAI enables AI agents to asynchronously authorize users.
Create an Auth0 Account and a Dev Tenant
Create an Auth0 Application
Regular Web
http://localhost:3000/auth/callback
http://localhost:3000
Enable CIBA Grant
Enable Guardian Push
Enroll your user to use Auth0 Guardian
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.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.withAsyncUserConfirmation()
. Let’s create a helper function to wrap the tool with the Async authorizer.Create a file at src/lib/auth0-ai.ts
and instantiate a new Auth0 AI SDK client:/token
endpoint for a user response.bindingMessage
containing the consent details, in this case, the details of the product to purchase.src/lib/auth0.ts
:/src/app/api/chat/[..._path]/route.ts
file with the following code. The user
will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.src/lib/tools/shop-online.ts
and add the following code:.env.local
file with the following variables:src/lib/agent.ts
file with the following code:npm run all:dev
. Then, navigate to http://localhost:3000
.