Skip to content

Conversation

@PavelKorobchuk
Copy link
Contributor

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Updated next quick-start examples according to the updated updated langgraph-nextjs-api-passthrough usage flow:

  • asynchronous-authorization/langchain-next-js
  • authenticate-users/langchain-next-js
  • authorization-for-rag/langchain-next-js
  • call-apis-on-users-behalf/others-api
  • call-apis-on-users-behalf/yours-api

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not the default branch

@priley86
Copy link
Contributor

priley86 commented Sep 29, 2025

two things:

  • lets make sure to include "Create an Auth0 API" pre-req in all of these examples moving forward (since we will need that when validating AUTH0_AUDIENCE. The existing builtin Prereq there looks fine to me... lets enable it w/ createAuth0ApiStep prop
  • For call-apis-on-users-behalf/others-api example specifically, lets be sure to include the Create Custom API Client language (b'c we are using 3rd party API access w/ Token Vault and will require it there). Please have a look at feat: calling-others-apis, adds LangGraph.js + React SPA quickstart #82 for more details on including that (slightly different here as we are coming from Next.js rather than SPA, but this should be similar).


Next, add the following code to `src/lib/auth0.ts`:

```tsx src/lib/auth0.ts wrap lines highlight={2-5}
Copy link
Contributor

Choose a reason for hiding this comment

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

highlight lines would need update, can you plz update that for all updated code blocks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
```
Then, in your auth.mts file, add your auth logic:
```typescript ./auth.mts wrap lines
Copy link
Contributor

Choose a reason for hiding this comment

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

is the path for auth.mts correct? shoudlnt it be src/lib/auth.mts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Updated paths everywhere

```
Then, in your auth.mts file, add your auth logic:
```typescript ./auth.mts wrap lines
import { createRemoteJWKSet, jwtVerify } from "jose";
Copy link
Contributor

Choose a reason for hiding this comment

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

are the dependencoes needed for this available in a new app (try deleting node_modules, install again and test)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added these packages in this PR

import { initApiPassthrough } from "langgraph-nextjs-api-passthrough";

import { getUser } from "@/lib/auth0";
import { getUser, getAccessToken } from "@/lib/auth0";
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont see a point of updating the rag quickstart as this change is not required for this quiclkstart to work at all. Its ok to update the sample app as good practice but I think the quickstart need not be updated. I'll leave the decision to you @KarimTantawy5

Copy link
Contributor

Choose a reason for hiding this comment

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

As in access token is not used in the RAG tool so adding all this in this quickstart doesnt serve any purpose.

...payload,
};
} catch (jwtError) {
...
Copy link
Contributor

Choose a reason for hiding this comment

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

whats happening here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added logic in catch block

...payload,
};
} catch (jwtError) {
...
Copy link
Contributor

Choose a reason for hiding this comment

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

??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added logic in catch block

...payload,
};
} catch (jwtError) {
...
Copy link
Contributor

Choose a reason for hiding this comment

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

???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added logic in catch block

priley86
priley86 previously approved these changes Sep 30, 2025
import { AccountAndAppSteps } from "/snippets/get-started/prerequisites/account-app-steps.jsx";

<Prerequisites />
<Prerequisites createAuth0ApiStep={{}} />
Copy link
Contributor

Choose a reason for hiding this comment

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

is API needed? I thought its only required for the calling other API one. @priley86 can you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

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

from my standpoint, yes... we are passing user information potentially across the network, and referencing it with regards to buying a product. We should try to validate the source of the requestor and that proper authorization is in place for the API.

}
```
Then, in your auth.ts file, add your auth logic:
```typescript ./src/lib/auth.ts wrap lines
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```typescript ./src/lib/auth.ts wrap lines
```typescript src/lib/auth.ts wrap lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

### Require async authorization for your tool

Call the tool from your AI app to make purchases. Update the `src/lib/agent.ts` file with the following code:
Call the tool from your AI app to make purchases. Update the `./src/lib/agent.ts` file with the following code:
Copy link
Contributor

Choose a reason for hiding this comment

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

can we keep it consistent plz, throughout the quickstarts we have src/...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Call the tool from your AI app to make purchases. Update the `./src/lib/agent.ts` file with the following code:

```ts src/lib/agent.ts wrap lines highlight={2,3,9}
```ts ./src/lib/agent.ts wrap lines highlight={2,3,9}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```ts ./src/lib/agent.ts wrap lines highlight={2,3,9}
```ts src/lib/agent.ts wrap lines highlight={2,3,9}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

import { AccountAndAppSteps } from "/snippets/get-started/prerequisites/account-app-steps.jsx";

<Prerequisites />
<Prerequisites createAuth0ApiStep={{}} />
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed??

import { AccountAndAppSteps } from "/snippets/get-started/prerequisites/account-app-steps.jsx";

<Prerequisites />
<Prerequisites createAuth0ApiStep={{}} />
Copy link
Contributor

Choose a reason for hiding this comment

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

is it necessary?

}
```
Then, in your auth.ts file, add your auth logic:
```typescript ./src/lib/auth.ts wrap lines
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```typescript ./src/lib/auth.ts wrap lines
```typescript src/lib/auth.ts wrap lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

### Add the tool to the AI agent
The AI agent processes and runs the user's request through the AI pipeline, including the tool call. Update the `/src/lib/agent.ts` file to add the tool to the agent.
The AI agent processes and runs the user's request through the AI pipeline, including the tool call. Update the `./src/lib/agent.ts` file to add the tool to the agent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The AI agent processes and runs the user's request through the AI pipeline, including the tool call. Update the `./src/lib/agent.ts` file to add the tool to the agent.
The AI agent processes and runs the user's request through the AI pipeline, including the tool call. Update the `src/lib/agent.ts` file to add the tool to the agent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

The AI agent processes and runs the user's request through the AI pipeline, including the tool call. Update the `./src/lib/agent.ts` file to add the tool to the agent.
```ts src/lib/agent.ts wrap lines highlight={2,8}
```ts ./src/lib/agent.ts wrap lines highlight={2,8}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```ts ./src/lib/agent.ts wrap lines highlight={2,8}
```ts src/lib/agent.ts wrap lines highlight={2,8}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Then, in your auth.mts file, add your auth logic:
```typescript ./auth.mts wrap lines
Then, in your auth.ts file, add your auth logic:
```typescript ./src/lib/auth.ts wrap lines
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```typescript ./src/lib/auth.ts wrap lines
```typescript src/lib/auth.ts wrap lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

priley86
priley86 previously approved these changes Oct 1, 2025
```

Update the `/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.
Update the `/src/app/api/chat/[..._path]/route.ts` file with the following code. AccessToken will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Update the `/src/app/api/chat/[..._path]/route.ts` file with the following code. AccessToken will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.
Update the `/src/app/api/chat/[..._path]/route.ts` file with the following code. AccessToken will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.
Suggested change
Update the `/src/app/api/chat/[..._path]/route.ts` file with the following code. AccessToken will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.
Update the `/src/app/api/chat/[..._path]/route.ts` file with the following code. The access token will be passed to your LangGraph agent so we can use it from the Auth0 AI SDK to get the current user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

### Add Custom Authentication
<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
For more information on how to add custom authentication for your LangGraph Platform application, read the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
</Info>
In your langgraph.json, add the path to your auth file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In your langgraph.json, add the path to your auth file:
In your `langgraph.json`, add the path to your auth file:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Now, update the `/src/lib/agent.ts` file with the following code to add the tool to your agent:
### Add Custom Authentication
<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
For more information on how to add custom authentication for your LangGraph Platform application, read the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
</Info>
In your langgraph.json, add the path to your auth file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In your langgraph.json, add the path to your auth file:
In your `langgraph.json`, add the path to your auth file:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
</Info>
In your langgraph.json, add the path to your auth file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In your langgraph.json, add the path to your auth file:
In your `langgraph.json`, add the path to your auth file:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
}
```
Then, in your auth.ts file, add your auth logic:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Then, in your auth.ts file, add your auth logic:
Then, in your `auth.ts` file, add your auth logic:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

### Add Custom Authentication
<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
For more information on how to add custom authentication for your LangGraph Platform application, read the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<Info>
For more information on how to add custom authentication for your LangGraph Platform application, see the [Custom Auth](https://langchain-ai.github.io/langgraphjs/how-tos/auth/custom_auth/) guide.
</Info>
In your langgraph.json, add the path to your auth file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In your langgraph.json, add the path to your auth file:
In your `langgraph.json`, add the path to your auth file:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
}
```
Then, in your auth.ts file, add your auth logic:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Then, in your auth.ts file, add your auth logic:
Then, in your `auth.ts` file, add your auth logic:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@KarimTantawy5 KarimTantawy5 left a comment

Choose a reason for hiding this comment

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

Looks good

@priley86 priley86 merged commit ed47b50 into auth0:main Oct 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants