Skip to content

Commit eadd0c2

Browse files
committed
feat: adds JS Token Vault + CIBA renaming updates
1 parent e9ff275 commit eadd0c2

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
@@ -150,7 +150,7 @@ To configure the Token Vault for your Google connection, you can use the followi
150150
```tsx wrap lines
151151
const auth0AI = new Auth0AI();
152152

153-
export const withGoogleConnection = auth0AI.withTokenForConnection({
153+
export const withGoogleConnection = auth0AI.withTokenVault({
154154
connection: "google-oauth2",
155155
scopes: ["https://www.googleapis.com/auth/calendar.freebusy", ...],
156156
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
@@ -147,7 +147,7 @@ async def api_route(
147147

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

150-
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.
150+
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.
151151

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

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
@@ -256,7 +256,7 @@ async def list_upcoming_events_fn():
256256
google_access_token = get_access_token_from_token_vault()
257257
if not google_access_token:
258258
raise ValueError(
259-
"Authorization required to access the Federated Connection API"
259+
"Authorization required to access the Token Vault connection API"
260260
)
261261

262262
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
@@ -36,7 +36,7 @@ Integrate the Auth0 AI SDK into your application to secure your async AI agent w
3636

3737
#### Configure the Auth0 AI SDK
3838

39-
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.
39+
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.
4040

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

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

4747
const auth0AI = new Auth0AI();
4848

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

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

81-
- The CIBA request includes the user ID that will approve the request.
81+
- The Async Authorization request includes the user ID that will approve the request.
8282
- Auth0 sends the user a mobile push notification. The AI agent polls the `/token` endpoint for a user response.
8383
- The mobile application retrieves the `bindingMessage` containing the consent details, in this case, the details of the product to purchase.
8484
- The user responds to the request:
@@ -241,15 +241,15 @@ export { auth as authHandler };
241241
242242
#### Create a tool to call your API
243243
244-
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.
244+
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.
245245
246246
Now, create a file `src/lib/tools/shop-online.ts` and add the following code:
247247
248248
```ts src/lib/tools/shop-online.ts wrap lines
249249
import { tool } from "@langchain/core/tools";
250250
import { z } from "zod";
251251

252-
import { getCIBACredentials } from "@auth0/ai-langchain";
252+
import { getAsyncAuthorizationCredentials } from "@auth0/ai-langchain";
253253

254254
export const shopOnlineTool = tool(
255255
async ({ product, qty, priceLimit }) => {
@@ -272,7 +272,7 @@ export const shopOnlineTool = tool(
272272
priceLimit,
273273
};
274274

275-
const credentials = getCIBACredentials();
275+
const credentials = getAsyncAuthorizationCredentials();
276276
const accessToken = credentials?.accessToken;
277277

278278
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
@@ -149,7 +149,7 @@ const auth0AI = new Auth0AI({
149149
});
150150

151151
const withAccessTokenForConnection = (connection: string, scopes: string[]) =>
152-
auth0AI.withTokenForConnection({
152+
auth0AI.withTokenVault({
153153
connection,
154154
scopes,
155155
accessToken: async (_, config) => {
@@ -321,15 +321,15 @@ This example uses `GmailSearch` from the `@langchain/community` tools. This tool
321321
322322
```ts src/lib/tools/gmail-seatch.ts wrap lines highlight={10}
323323
//...
324-
import { getAccessTokenForConnection } from "@auth0/ai-langchain";
324+
import { getAccessTokenFromTokenVault } from "@auth0/ai-langchain";
325325
import { GmailSearch } from "@langchain/community/tools/gmail";
326326

327327
import { withGmailSearch } from "../../lib/auth0-ai";
328328

329329
export const gmailSearchTool = withGmailSearch(
330330
new GmailSearch({
331331
credentials: {
332-
accessToken: async () => getAccessTokenForConnection(),
332+
accessToken: async () => getAccessTokenFromTokenVault(),
333333
},
334334
})
335335
);
@@ -365,36 +365,36 @@ When you try to use the tool, the application requests any additional Google sco
365365
To implement, install the Auth0 AI Components for Next.js SDK to get the required UI components:
366366
367367
```bash wrap lines
368-
npx @auth0/ai-components add FederatedConnections
368+
npx @auth0/ai-components add TokenVault
369369
```
370370
371-
Add a new file, `src/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler.tsx`, with the following code:
371+
Add a new file, `src/components/auth0-ai/TokenVault/TokenVaultInterruptHandler.tsx`, with the following code:
372372
373-
```tsx src/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler.tsx wrap lines
374-
import { FederatedConnectionInterrupt } from "@auth0/ai/interrupts";
373+
```tsx src/components/auth0-ai/TokenVault/TokenVaultInterruptHandler.tsx wrap lines
374+
import { TokenVaultInterrupt } from "@auth0/ai/interrupts";
375375
import type { Interrupt } from "@langchain/langgraph-sdk";
376376

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

379-
interface FederatedConnectionInterruptHandlerProps {
379+
interface TokenVaultInterruptHandlerProps {
380380
interrupt: Interrupt | undefined | null;
381381
onFinish: () => void;
382382
}
383383

384-
export function FederatedConnectionInterruptHandler({
384+
export function TokenVaultInterruptHandler({
385385
interrupt,
386386
onFinish,
387-
}: FederatedConnectionInterruptHandlerProps) {
387+
}: TokenVaultInterruptHandlerProps) {
388388
if (
389389
!interrupt ||
390-
!FederatedConnectionInterrupt.isInterrupt(interrupt.value)
390+
!TokenVaultInterrupt.isInterrupt(interrupt.value)
391391
) {
392392
return null;
393393
}
394394

395395
return (
396396
<div key={interrupt.ns?.join("")} className="whitespace-pre-wrap">
397-
<EnsureAPIAccess
397+
<TokenVaultConsent
398398
mode="popup"
399399
interrupt={interrupt.value}
400400
onFinish={onFinish}
@@ -409,11 +409,11 @@ export function FederatedConnectionInterruptHandler({
409409
}
410410
```
411411
412-
Now, update your chat window code to include the `FederatedConnectionInterruptHandler` component, for example:
412+
Now, update your chat window code to include the `TokenVaultInterruptHandler` component, for example:
413413
414414
```tsx src/components/chat-window.tsx wrap lines highlight={2,3,8-19,36-38}
415415
//...
416-
import { FederatedConnectionInterruptHandler } from '@/components/auth0-ai/FederatedConnections/FederatedConnectionInterruptHandler';
416+
import { TokenVaultInterruptHandler } from '@/components/auth0-ai/TokenVault/TokenVaultInterruptHandler';
417417

418418
//... existing code
419419
export function ChatWindow(props: {
@@ -448,7 +448,7 @@ export function ChatWindow(props: {
448448
emptyStateComponent={props.emptyStateComponent}
449449
/>
450450
<div className="flex flex-col max-w-[768px] mx-auto pb-12 w-full">
451-
<FederatedConnectionInterruptHandler interrupt={chat.interrupt} onFinish={() => chat.submit(null)} />
451+
<TokenVaultInterruptHandler interrupt={chat.interrupt} onFinish={() => chat.submit(null)} />
452452
</div>
453453
</>
454454
)

0 commit comments

Comments
 (0)