Skip to content

Commit acc7271

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

Some content is hidden

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

46 files changed

+1662
-304
lines changed

auth4genai/how-tos/analyze-strava-activities.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Before using this example, make sure you:
2020
## 1. Define the Vercel AI Tool and backend API Route
2121

2222
Define a `getActivities` tool that uses GPT-4 to fetch and analyze a user's recent fitness activity from Strava:
23-
- When the tool calls `getAccessTokenForConnection()` to fetch a Spotify access token, pass in `strava-custom` as the connection name.
23+
- When the tool calls `getAccessTokenFromTokenVault()` to fetch a Spotify access token, pass in `strava-custom` as the connection name.
2424

2525
```tsx wrap lines
2626
import { openai } from "@ai-sdk/openai"
@@ -48,7 +48,7 @@ export async function POST(req) {
4848
limit: z.number().default(5).describe("Number of activities to fetch"),
4949
}),
5050
execute: async ({ limit }) => {
51-
const { token: accessToken } = await auth0.getAccessTokenForConnection({ connection: "strava-custom" });
51+
const { token: accessToken } = await auth0.getAccessTokenFromTokenVault({ connection: "strava-custom" });
5252

5353
const url = `https://www.strava.com/api/v3/athlete/activities?per_page=${limit}`;
5454

auth4genai/how-tos/create-spotify-playlist.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Before using this example, make sure you:
2323
## 1. Define the Vercel AI Tool and backend API Route
2424

2525
Define a `createPlaylist` tool that uses GPT-4 to create a new Spotify playlist for the user:
26-
- When the tool calls `getAccessTokenForConnection()` to fetch a Spotify access token, pass in `spotify-custom` as the connection name.
26+
- When the tool calls `getAccessTokenFromTokenVault()` to fetch a Spotify access token, pass in `spotify-custom` as the connection name.
2727

2828
```tsx wrap app/api/chat/route.js lines
2929
import { openai } from "@ai-sdk/openai"
@@ -47,7 +47,7 @@ export async function POST(req) {
4747
description: z.string().describe("Optional description of the playlist"),
4848
}),
4949
execute: async ({ description }) => {
50-
const { token: accessToken } = await auth0.getAccessTokenForConnection({ connection: "spotify-custom" });
50+
const { token: accessToken } = await auth0.getAccessTokenFromTokenVault({ connection: "spotify-custom" });
5151
// search for songs based on description
5252
const query = new URLSearchParams({
5353
q: description,

auth4genai/how-tos/get-salesforce-opportunities.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SALESFORCE_INSTANCE_URL=https://your-instance.salesforce.com
3131

3232
Create an AI tool that gets a list of opportunities from Salesforce and a backend route that uses Auth0 to get a Salesforce access token:
3333

34-
- When the tool calls `auth0.getAccessTokenForConnection()`, pass `sfdc` as the connection name to get a Salesforce access token.
34+
- When the tool calls `auth0.getAccessTokenFromTokenVault()`, pass `sfdc` as the connection name to get a Salesforce access token.
3535

3636
```tsx app/api/chat/route.js wrap lines
3737
import { openai } from "@ai-sdk/openai";
@@ -70,7 +70,7 @@ export async function POST(req) {
7070
const url = `${instanceUrl}/services/data/v57.0/${endpoint}`;
7171

7272
// call auth0 to get the access token
73-
const { accessToken } = await auth0.getAccessTokenForConnection({
73+
const { accessToken } = await auth0.getAccessTokenFromTokenVault({
7474
connection: "sfdc",
7575
});
7676

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

0 commit comments

Comments
 (0)