Skip to content

Commit e32228d

Browse files
committed
feat: adds JS Token Vault + CIBA renaming updates
1 parent 83b8bb3 commit e32228d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1656
-298
lines changed

auth4genai/integrations/github.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ To configure the Token Vault for your GitHub connection, you can use the followi
8383
```tsx wrap lines
8484
const auth0AI = new Auth0AI();
8585

86-
export const withGitHubConnection = auth0AI.withTokenForConnection({
86+
export const withGitHubConnection = auth0AI.withTokenVault({
8787
connection: "github",
8888
// scopes are not supported for GitHub yet. Set required scopes when creating the accompanying GitHub app
8989
scopes: [],

auth4genai/integrations/google.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ To configure the Token Vault for your Google connection, you can use the followi
163163
```tsx wrap lines
164164
const auth0AI = new Auth0AI();
165165

166-
export const withGoogleConnection = auth0AI.withTokenForConnection({
166+
export const withGoogleConnection = auth0AI.withTokenVault({
167167
connection: "google-oauth2",
168168
scopes: ["https://www.googleapis.com/auth/calendar.freebusy", ...],
169169
refreshToken: getAuth0RefreshToken(),

auth4genai/integrations/slack.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ To configure the Token Vault for your GitHub connection, you can use the followi
8484
```tsx wrap lines
8585
const auth0AI = new Auth0AI();
8686

87-
export const withSlackConnection = auth0AI.withTokenForConnection({
87+
export const withSlackConnection = auth0AI.withTokenVault({
8888
connection: "sign-in-with-slack",
8989
scopes: ["channels:read", ...],
9090
refreshToken: getAuth0RefreshToken(),

auth4genai/intro/call-others-apis-on-users-behalf.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Call Other's APIs on User's Behalf
3-
description: "[Token Vault](/intro/token-vault) lets your AI agent call external APIs on the user's behalf. We provide SDKs for Python, JavaScript, and popular AI frameworks like LangChain, LlamaIndex, Genkit, and Vercel AI, making it easy and straightforward to get access tokens for your federated connections."
3+
description: "[Token Vault](/intro/token-vault) lets your AI agent call external APIs on the user's behalf. We provide SDKs for Python, JavaScript, and popular AI frameworks like LangChain, LlamaIndex, Genkit, and Vercel AI, making it easy and straightforward to get access tokens for your third-party connections."
44
---
55

66
## Web applications with backend for frontend
@@ -135,4 +135,4 @@ To begin using Auth0 Token Vault with your AI agents, refer to the following res
135135
icon="key"
136136
horizontal
137137
/>
138-
</Columns>
138+
</Columns>

auth4genai/intro/token-vault.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ By using Token Vault, you can:
4747
The process of using Token Vault involves the following key steps:
4848

4949
1. **User authentication and consent:** The [user links](/intro/account-linking) and authenticates with an external Identity Provider (e.g., Google) and grants your application permission to access their data by approving the requested OAuth scopes.
50-
2. **Secure token storage:** Auth0 receives the federated access and refresh tokens from the external provider and stores them securely within Token Vault.
51-
3. **Token exchange:** Your application can then exchange a valid Auth0 refresh token for a federated access token from Token Vault. This allows your application to obtain the necessary credentials to call the third-party API without the user having to re-authenticate. It also means your application does not need to store or manage any credentials.
52-
4. **API call:** With the federated access token, your AI agent can make authorized calls to the third-party API on the user's behalf.
50+
2. **Secure token storage:** Auth0 receives access and refresh tokens from the external provider and stores them securely within Token Vault.
51+
3. **Token exchange:** Your application can then exchange a valid Auth0 refresh token for a third-party access token from Token Vault. This allows your application to obtain the necessary credentials to call the third-party API without the user having to re-authenticate. It also means your application does not need to store or manage any credentials.
52+
4. **API call:** With the third-party access token, your AI agent can make authorized calls to the third-party API on the user's behalf.
5353

5454
## Supported integrations
5555

auth4genai/sdks/javascript-sdk.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This library helps to set up the React components that can be used in AI applica
6363
- Tools for getting access tokens for supported social and enterprise identity providers
6464

6565
```bash wrap lines
66-
npx @auth0/ai-components add FederatedConnections
66+
npx @auth0/ai-components add TokenVault
6767
```
6868

6969
### [Redis Store for Auth0 AI](https://github.com/auth0-lab/auth0-ai-js/tree/main/packages/ai-redis)

auth4genai/snippets/get-started/langchain-fastapi-py/async-auth.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def api_route(
146146

147147
#### Create a tool to call your API
148148

149-
In this example, we use a tool that buys products on the user's behalf. When the user approves the transaction, the Auth0 AI SDK retrieves an access token to call the shop's API. Upon completing the CIBA flow, the AI agent responds with a message confirming the purchase. The Auth0 AI SDK returns an error response if the user denies the transaction.
149+
In this example, we use a tool that buys products on the user's behalf. When the user approves the transaction, the Auth0 AI SDK retrieves an access token to call the shop's API. Upon completing the Async Authorization flow, the AI agent responds with a message confirming the purchase. The Auth0 AI SDK returns an error response if the user denies the transaction.
150150

151151
Now, create a file `app/agents/tools/shop_online.py` and add the following code:
152152

auth4genai/snippets/get-started/langchain-fastapi-py/call-others-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def list_upcoming_events_fn():
257257
google_access_token = get_access_token_from_token_vault()
258258
if not google_access_token:
259259
raise ValueError(
260-
"Authorization required to access the Federated Connection API"
260+
"Authorization required to access the Token Vault connection API"
261261
)
262262

263263
calendar_service = build(

auth4genai/snippets/get-started/langchain-next-js/async-auth.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Integrate the Auth0 AI SDK into your application to secure your async AI agent w
3535

3636
#### Configure the Auth0 AI SDK
3737

38-
To require asynchronous authorization for your tool, the tool needs to be wrapped with the Async authorizer, `withAsyncUserConfirmation()`. Let's create a helper function to wrap the tool with the Async authorizer.
38+
To require asynchronous authorization for your tool, the tool needs to be wrapped with the Async authorizer, `withAsyncAuthorization()`. Let's create a helper function to wrap the tool with the Async authorizer.
3939

4040
Create a file at `src/lib/auth0-ai.ts` and instantiate a new Auth0 AI SDK client:
4141

@@ -45,8 +45,8 @@ import { AccessDeniedInterrupt } from "@auth0/ai/interrupts";
4545

4646
const auth0AI = new Auth0AI();
4747

48-
// CIBA flow for user confirmation
49-
export const withAsyncAuthorization = auth0AI.withAsyncUserConfirmation({
48+
// Async Authorization flow for user confirmation
49+
export const withAsyncAuthorization = auth0AI.withAsyncAuthorization({
5050
userID: async (_params, config) => {
5151
return config.configurable?.langgraph_auth_user?.sub;
5252
},
@@ -75,9 +75,9 @@ export const withAsyncAuthorization = auth0AI.withAsyncUserConfirmation({
7575
});
7676
```
7777

78-
This will intercept the tool call to initiate a CIBA request:
78+
This will intercept the tool call to initiate a Async Authorization request:
7979

80-
- The CIBA request includes the user ID that will approve the request.
80+
- The Async Authorization request includes the user ID that will approve the request.
8181
- Auth0 sends the user a mobile push notification. The AI agent polls the `/token` endpoint for a user response.
8282
- The mobile application retrieves the `bindingMessage` containing the consent details, in this case, the details of the product to purchase.
8383
- The user responds to the request:
@@ -240,15 +240,15 @@ export { auth as authHandler };
240240
241241
#### Create a tool to call your API
242242
243-
In this example, we use a tool that buys products on the user's behalf. When the user approves the transaction, the Auth0 AI SDK retrieves an access token to call the shop's API. Upon completing the CIBA flow, the AI agent responds with a message confirming the purchase. The Auth0 AI SDK returns an error response if the user denies the transaction.
243+
In this example, we use a tool that buys products on the user's behalf. When the user approves the transaction, the Auth0 AI SDK retrieves an access token to call the shop's API. Upon completing the Async Authorization flow, the AI agent responds with a message confirming the purchase. The Auth0 AI SDK returns an error response if the user denies the transaction.
244244
245245
Now, create a file `src/lib/tools/shop-online.ts` and add the following code:
246246
247247
```ts src/lib/tools/shop-online.ts wrap lines
248248
import { tool } from "@langchain/core/tools";
249249
import { z } from "zod";
250250

251-
import { getCIBACredentials } from "@auth0/ai-langchain";
251+
import { getAsyncAuthorizationCredentials } from "@auth0/ai-langchain";
252252

253253
export const shopOnlineTool = tool(
254254
async ({ product, qty, priceLimit }) => {
@@ -271,7 +271,7 @@ export const shopOnlineTool = tool(
271271
priceLimit,
272272
};
273273

274-
const credentials = getCIBACredentials();
274+
const credentials = getAsyncAuthorizationCredentials();
275275
const accessToken = credentials?.accessToken;
276276

277277
if (accessToken) {

auth4genai/snippets/get-started/langchain-next-js/call-others-api.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const auth0AI = new Auth0AI({
155155
});
156156

157157
const withAccessTokenForConnection = (connection: string, scopes: string[]) =>
158-
auth0AI.withTokenForConnection({
158+
auth0AI.withTokenVault({
159159
connection,
160160
scopes,
161161
accessToken: async (_, config) => {
@@ -327,15 +327,15 @@ This example uses `GmailSearch` from the `@langchain/community` tools. This tool
327327
328328
```ts src/lib/tools/gmail-seatch.ts wrap lines highlight={10}
329329
//...
330-
import { getAccessTokenForConnection } from "@auth0/ai-langchain";
330+
import { getAccessTokenFromTokenVault } from "@auth0/ai-langchain";
331331
import { GmailSearch } from "@langchain/community/tools/gmail";
332332

333333
import { withGmailSearch } from "../../lib/auth0-ai";
334334

335335
export const gmailSearchTool = withGmailSearch(
336336
new GmailSearch({
337337
credentials: {
338-
accessToken: async () => getAccessTokenForConnection(),
338+
accessToken: async () => getAccessTokenFromTokenVault(),
339339
},
340340
})
341341
);
@@ -371,36 +371,36 @@ When you try to use the tool, the application requests any additional Google sco
371371
To implement, install the Auth0 AI Components for Next.js SDK to get the required UI components:
372372
373373
```bash wrap lines
374-
npx @auth0/ai-components add FederatedConnections
374+
npx @auth0/ai-components add TokenVault
375375
```
376376
377-
Add a new file, `src/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler.tsx`, with the following code:
377+
Add a new file, `src/components/auth0-ai/TokenVault/TokenVaultInterruptHandler.tsx`, with the following code:
378378
379-
```tsx src/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler.tsx wrap lines
380-
import { FederatedConnectionInterrupt } from "@auth0/ai/interrupts";
379+
```tsx src/components/auth0-ai/TokenVault/TokenVaultInterruptHandler.tsx wrap lines
380+
import { TokenVaultInterrupt } from "@auth0/ai/interrupts";
381381
import type { Interrupt } from "@langchain/langgraph-sdk";
382382

383-
import { EnsureAPIAccess } from "@/components/auth0-ai/FederatedConnections";
383+
import { TokenVaultConsent } from "@/components/auth0-ai/TokenVault";
384384

385-
interface FederatedConnectionInterruptHandlerProps {
385+
interface TokenVaultInterruptHandlerProps {
386386
interrupt: Interrupt | undefined | null;
387387
onFinish: () => void;
388388
}
389389

390-
export function FederatedConnectionInterruptHandler({
390+
export function TokenVaultInterruptHandler({
391391
interrupt,
392392
onFinish,
393-
}: FederatedConnectionInterruptHandlerProps) {
393+
}: TokenVaultInterruptHandlerProps) {
394394
if (
395395
!interrupt ||
396-
!FederatedConnectionInterrupt.isInterrupt(interrupt.value)
396+
!TokenVaultInterrupt.isInterrupt(interrupt.value)
397397
) {
398398
return null;
399399
}
400400

401401
return (
402402
<div key={interrupt.ns?.join("")} className="whitespace-pre-wrap">
403-
<EnsureAPIAccess
403+
<TokenVaultConsent
404404
mode="popup"
405405
interrupt={interrupt.value}
406406
onFinish={onFinish}
@@ -415,11 +415,11 @@ export function FederatedConnectionInterruptHandler({
415415
}
416416
```
417417
418-
Now, update your chat window code to include the `FederatedConnectionInterruptHandler` component, for example:
418+
Now, update your chat window code to include the `TokenVaultInterruptHandler` component, for example:
419419
420420
```tsx src/components/chat-window.tsx wrap lines highlight={2,3,8-19,36-38}
421421
//...
422-
import { FederatedConnectionInterruptHandler } from '@/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler';
422+
import { TokenVaultInterruptHandler } from '@/components/auth0-ai/TokenVault/TokenVaultInterruptHandler';
423423

424424
//... existing code
425425
export function ChatWindow(props: {
@@ -454,7 +454,7 @@ export function ChatWindow(props: {
454454
emptyStateComponent={props.emptyStateComponent}
455455
/>
456456
<div className="flex flex-col max-w-[768px] mx-auto pb-12 w-full">
457-
<FederatedConnectionInterruptHandler interrupt={chat.interrupt} onFinish={() => chat.submit(null)} />
457+
<TokenVaultInterruptHandler interrupt={chat.interrupt} onFinish={() => chat.submit(null)} />
458458
</div>
459459
</>
460460
)

0 commit comments

Comments
 (0)