Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion py-langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Next, you'll need to set up environment variables in your repo's `.env` file. Co
To start with the basic examples, you'll just need to add your OpenAI API key and Auth0 credentials.

- To start with the examples, you'll just need to add your OpenAI API key and Auth0 credentials for the Web app.
- You can setup a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/call-others-apis-on-users-behalf).
- You can set up a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/get-started/call-others-apis-on-users-behalf).
- An Auth0 FGA account, you can create one [here](https://dashboard.fga.dev). Add the FGA store ID, client ID, client secret, and API URL to the `.env` file.

Next, install the required packages using your preferred package manager, e.g. uv:
Expand Down
2 changes: 1 addition & 1 deletion py-langchain/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You'll need to set up environment variables in your repo's `.env` file. Copy the
To start with the basic examples, you'll just need to add your OpenAI API key and Auth0 credentials.

- To start with the examples, you'll just need to add your OpenAI API key and Auth0 credentials for the Web app.
- You can setup a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/call-others-apis-on-users-behalf).
- You can set up a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/get-started/call-others-apis-on-users-behalf).
- An Auth0 FGA account, you can create one [here](https://dashboard.fga.dev). Add the FGA store ID, client ID, client secret, and API URL to the `.env` file.
Copy link
Contributor

@priley86 priley86 Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this py-langchain example, on the backend it seems like we will need the equivalent of:

export const auth0 = new Auth0Client({
  enableConnectAccountEndpoint: true,
});

updated in the python sdk?

Also, seems we could likely also include the openid scope within:
https://github.com/auth0-samples/auth0-assistant0/blob/main/py-langchain/backend/app/core/auth0_ai.py#L17-L20

yes? (leaving as a reminder for later if this is the case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we'll need this change: auth0/auth0-fastapi#67
And this one: auth0/auth0-ai-python#55


Next, install the required packages using your preferred package manager, e.g. uv:
Expand Down
20 changes: 10 additions & 10 deletions py-langchain/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion py-langchain/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@auth0/ai": "^5.0.1",
"@auth0/ai": "^5.1.1",
"@langchain/core": "^0.3.66",
"@langchain/langgraph-sdk": "^0.0.109",
"@radix-ui/react-avatar": "^1.1.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import type { ReactNode } from "react";

/**
* Defines the mode the EnsureAPIAccess component will use to prompt the user to authorize the API access.
* Defines the mode the TokenVaultConsent component will use to prompt the user to connect a third-party account and
* authorize the API access.
* - `redirect` will redirect the user to the provider's authorization page.
* - `popup` will open a popup window to prompt the user to authorize the API access.
* - `auto` will automatically choose the best mode based on the user's device and browser.
Expand All @@ -13,10 +14,11 @@ export type TokenVaultAuthProps = {
interrupt: {
connection: string;
requiredScopes: string[];
authorizationParams?: Record<string, string>;
resume?: () => void;
};
auth?: {
authorizePath?: string;
connectPath?: string;
returnTo?: string;
};
onFinish?: () => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BrowserView, MobileView } from "react-device-detect";

import type { TokenVaultAuthProps } from "./TokenVaultAuthProps";
import { TokenVaultConsentPopup } from "./popup";
import { TokenVaultConsentRedirect } from "./redirect";
import type { TokenVaultAuthProps } from "./TokenVaultAuthProps";

export function TokenVaultConsent(props: TokenVaultAuthProps) {
const { mode } = props;
Expand Down
20 changes: 12 additions & 8 deletions py-langchain/frontend/src/components/auth0-ai/TokenVault/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useCallback, useEffect, useState } from "react";

import { WaitingMessage } from "../util/loader";
import { PromptUserContainer } from "../util/prompt-user-container";

import type { TokenVaultAuthProps } from "./TokenVaultAuthProps";

export function TokenVaultConsentPopup({
interrupt: { connection, requiredScopes, resume },
interrupt: { connection, requiredScopes, authorizationParams, resume },
connectWidget: { icon, title, description, action, containerClassName },
auth: { authorizePath = "/auth/login", returnTo = "/close" } = {},
auth: { connectPath = "/auth/connect", returnTo = "/close" } = {},
onFinish,
}: TokenVaultAuthProps) {
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -43,14 +44,17 @@ export function TokenVaultConsentPopup({
//Open the login popup
const startLoginPopup = useCallback(async () => {
const search = new URLSearchParams({
returnTo,
connection,
access_type: "offline",
prompt: "consent",
connection_scope: requiredScopes.join(),
returnTo,
// Add all extra authorization parameters to the search params, they will be collected and submitted via the
// authorization_params parameter of the connect account flow.
...authorizationParams,
});
for (const requiredScope of requiredScopes) {
search.append("scopes", requiredScope);
}

const url = new URL(authorizePath, window.location.origin);
const url = new URL(connectPath, window.location.origin);
url.search = search.toString();

const windowFeatures =
Expand All @@ -63,7 +67,7 @@ export function TokenVaultConsentPopup({
setLoginPopup(popup);
setIsLoading(true);
}
}, [connection, requiredScopes, returnTo, authorizePath]);
}, [connection, requiredScopes, returnTo, authorizationParams, connectPath]);

if (isLoading) {
return <WaitingMessage />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"use client";

import { PromptUserContainer } from "../util/prompt-user-container";

import type { TokenVaultAuthProps } from "./TokenVaultAuthProps";

export function TokenVaultConsentRedirect({
interrupt: { requiredScopes, connection },
interrupt: { connection, requiredScopes, authorizationParams },
connectWidget: { icon, title, description, action, containerClassName },
auth: {
authorizePath = "/auth/login",
connectPath = "/auth/connect",
returnTo = window.location.pathname,
} = {},
}: TokenVaultAuthProps) {
Expand All @@ -21,13 +22,17 @@ export function TokenVaultConsentRedirect({
label: action?.label ?? "Connect",
onClick: () => {
const search = new URLSearchParams({
returnTo,
connection,
access_type: "offline",
connection_scope: requiredScopes.join(),
returnTo,
// Add all extra authorization parameters to the search params, they will be collected and submitted via the
// authorization_params parameter of the connect account flow.
...authorizationParams,
});
for (const requiredScope of requiredScopes) {
search.append("scopes", requiredScope);
}

const url = new URL(authorizePath, window.location.origin);
const url = new URL(connectPath, window.location.origin);
url.search = search.toString();

// Redirect to the authorization page
Expand Down
2 changes: 1 addition & 1 deletion py-langchain/frontend/src/components/chat-window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useStream } from "@langchain/langgraph-sdk/react";
import { type Message } from "@langchain/langgraph-sdk";

import { ChatMessageBubble } from "@/components/chat-message-bubble";
import { TokenVaultInterruptHandler } from "@/components/auth0-ai/TokenVault/TokenVaultInterruptHandler";
import { TokenVaultInterruptHandler } from "@/components/TokenVaultInterruptHandler";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { getLoginUrl } from "@/lib/use-auth";
Expand Down
122 changes: 122 additions & 0 deletions scripts/update_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/bin/bash

# Script to update @auth0/ai packages to their latest versions
# Usage: ./update_packages.sh

set -e

# Define the versions
AUTH0_SPA_JS_VERSION="^2.9.0"
AUTH0_NEXTJS_VERSION="^4.13.0"
AUTH0_AI_VERSION="^5.1.1"
AUTH0_AI_VERCEL_VERSION="^4.1.0"
AUTH0_AI_LANGCHAIN_VERSION="^4.1.0"
AUTH0_AI_LLAMAINDEX_VERSION="^4.1.0"

REGISTRY="--registry https://registry.npmjs.org/"

echo "Starting package updates..."

# Function to update a package.json file and reinstall packages
update_package_json() {
local file="$1"
local updated=false

echo "Checking $file..."

if grep -q '"@auth0/auth0-spa-js"' "$file"; then
echo " Updating @auth0/auth0-spa-js to $AUTH0_SPA_JS_VERSION"
sed -i '' 's/"@auth0\/auth0-spa-js": "[^"]*"/"@auth0\/auth0-spa-js": "'$AUTH0_SPA_JS_VERSION'"/g' "$file"
updated=true
fi

if grep -q '"@auth0/nextjs-auth0"' "$file"; then
echo " Updating @auth0/nextjs-auth0 to $AUTH0_NEXTJS_VERSION"
sed -i '' 's/"@auth0\/nextjs-auth0": "[^"]*"/"@auth0\/nextjs-auth0": "'$AUTH0_NEXTJS_VERSION'"/g' "$file"
updated=true
fi

if grep -q '"@auth0/ai"' "$file"; then
echo " Updating @auth0/ai to $AUTH0_AI_VERSION"
sed -i '' 's/"@auth0\/ai": "[^"]*"/"@auth0\/ai": "'$AUTH0_AI_VERSION'"/g' "$file"
updated=true
fi

if grep -q '"@auth0/ai-vercel"' "$file"; then
echo " Updating @auth0/ai-vercel to $AUTH0_AI_VERCEL_VERSION"
sed -i '' 's/"@auth0\/ai-vercel": "[^"]*"/"@auth0\/ai-vercel": "'$AUTH0_AI_VERCEL_VERSION'"/g' "$file"
updated=true
fi

if grep -q '"@auth0/ai-langchain"' "$file"; then
echo " Updating @auth0/ai-langchain to $AUTH0_AI_LANGCHAIN_VERSION"
sed -i '' 's/"@auth0\/ai-langchain": "[^"]*"/"@auth0\/ai-langchain": "'$AUTH0_AI_LANGCHAIN_VERSION'"/g' "$file"
updated=true
fi

if grep -q '"@auth0/ai-llamaindex"' "$file"; then
echo " Updating @auth0/ai-llamaindex to $AUTH0_AI_LLAMAINDEX_VERSION"
sed -i '' 's/"@auth0\/ai-llamaindex": "[^"]*"/"@auth0\/ai-llamaindex": "'$AUTH0_AI_LLAMAINDEX_VERSION'"/g' "$file"
updated=true
fi

if [ "$updated" = true ]; then
echo " Updated $file"
dir=$(dirname "$file")

# Simple approach: collect all @auth0 packages, uninstall them, then reinstall
packages_to_uninstall=""
packages_to_reinstall=""

if grep -q '"@auth0/auth0-spa-js":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/auth0-spa-js"
packages_to_reinstall="$packages_to_reinstall @auth0/auth0-spa-js@$AUTH0_SPA_JS_VERSION"
fi

if grep -q '"@auth0/nextjs-auth0":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/nextjs-auth0"
packages_to_reinstall="$packages_to_reinstall @auth0/nextjs-auth0@$AUTH0_NEXTJS_VERSION"
fi

if grep -q '"@auth0/ai":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/ai"
packages_to_reinstall="$packages_to_reinstall @auth0/ai@$AUTH0_AI_VERSION"
fi

if grep -q '"@auth0/ai-vercel":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/ai-vercel"
packages_to_reinstall="$packages_to_reinstall @auth0/ai-vercel@$AUTH0_AI_VERCEL_VERSION"
fi

if grep -q '"@auth0/ai-langchain":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/ai-langchain"
packages_to_reinstall="$packages_to_reinstall @auth0/ai-langchain@$AUTH0_AI_LANGCHAIN_VERSION"
fi

if grep -q '"@auth0/ai-llamaindex":' "$file"; then
packages_to_uninstall="$packages_to_uninstall @auth0/ai-llamaindex"
packages_to_reinstall="$packages_to_reinstall @auth0/ai-llamaindex@$AUTH0_AI_LLAMAINDEX_VERSION"
fi

# Uninstall all @auth0 packages at once
if [ -n "$packages_to_uninstall" ]; then
echo " Uninstalling:$packages_to_uninstall"
(cd "$dir" && npm uninstall$packages_to_uninstall 2>/dev/null || true)
fi

# Reinstall all @auth0 packages at once
if [ -n "$packages_to_reinstall" ]; then
echo " Reinstalling:$packages_to_reinstall"
(cd "$dir" && npm install$packages_to_reinstall $REGISTRY)
fi
fi
}

# Find all package.json files and update them
find . -name "package.json" -type f -not -path "*/node_modules/*" | while read -r file; do
if grep -q '@auth0/ai' "$file"; then
update_package_json "$file"
fi
done

echo "Package updates completed!"
4 changes: 2 additions & 2 deletions ts-langchain/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ AUTH0_CLIENT_ID="{yourClientId}"
AUTH0_CLIENT_SECRET="{yourClientSecret}"
# Use your SHOP_API_AUDIENCE or a separate LangGraph API audience
AUTH0_AUDIENCE="https://your.domain.us.langgraph.app"
AUTH0_SCOPE="openid profile email"
AUTH0_SCOPE="openid profile email offline_access"
AUTH0_CUSTOM_API_CLIENT_ID="{yourCustomApiClientId}"
AUTH0_CUSTOM_API_CLIENT_SECRET="{yourCustomApiClientSecret}"

# Database configuration
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_documents_db"
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_documents_db"

# Auth0 FGA
FGA_STORE_ID=<your-fga-store-id>
Expand Down
4 changes: 2 additions & 2 deletions ts-langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Next, you'll need to set up environment variables in your repo's `.env.local` fi
To start with the basic examples, you'll just need to add your OpenAI API key and Auth0 credentials.

- To start with the examples, you'll just need to add your OpenAI API key and Auth0 credentials for the Web app and Machine to Machine App.
- You can setup a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/call-others-apis-on-users-behalf).
- You can set up a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/get-started/call-others-apis-on-users-behalf).
- An Auth0 FGA account, you can create one [here](https://dashboard.fga.dev). Add the FGA store ID, client ID, client secret, and API URL to the `.env.local` file.
- Optionally add a [SerpAPI](https://serpapi.com/) API key for using web search tool.

Expand Down Expand Up @@ -67,7 +67,7 @@ Agent configuration lives in `src/lib/agent.ts`. From here, you can change the p
This package has [@next/bundle-analyzer](https://www.npmjs.com/package/@next/bundle-analyzer) set up by default - you can explore the bundle size interactively by running:

```bash
$ ANALYZE=true bun run build
$ ANALYZE=true npm run build

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

## License
Expand Down
Loading