-
Notifications
You must be signed in to change notification settings - Fork 17
fix: updated quick-start examples with updated langgraph-nextjs-api-passthrough usage #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: updated quick-start examples with updated langgraph-nextjs-api-passthrough usage #100
Conversation
|
two things:
|
|
|
||
| Next, add the following code to `src/lib/auth0.ts`: | ||
|
|
||
| ```tsx src/lib/auth0.ts wrap lines highlight={2-5} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { | ||
| ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats happening here?
There was a problem hiding this comment.
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) { | ||
| ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
There was a problem hiding this comment.
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) { | ||
| ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
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
| import { AccountAndAppSteps } from "/snippets/get-started/prerequisites/account-app-steps.jsx"; | ||
|
|
||
| <Prerequisites /> | ||
| <Prerequisites createAuth0ApiStep={{}} /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```typescript ./src/lib/auth.ts wrap lines | |
| ```typescript src/lib/auth.ts wrap lines |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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/...
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```ts ./src/lib/agent.ts wrap lines highlight={2,3,9} | |
| ```ts src/lib/agent.ts wrap lines highlight={2,3,9} |
There was a problem hiding this comment.
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={{}} /> |
There was a problem hiding this comment.
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={{}} /> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```typescript ./src/lib/auth.ts wrap lines | |
| ```typescript src/lib/auth.ts wrap lines |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```ts ./src/lib/agent.ts wrap lines highlight={2,8} | |
| ```ts src/lib/agent.ts wrap lines highlight={2,8} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```typescript ./src/lib/auth.ts wrap lines | |
| ```typescript src/lib/auth.ts wrap lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| ``` | ||
|
|
||
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
| 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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| In your langgraph.json, add the path to your auth file: | |
| In your `langgraph.json`, add the path to your auth file: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| In your langgraph.json, add the path to your auth file: | |
| In your `langgraph.json`, add the path to your auth file: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| In your langgraph.json, add the path to your auth file: | |
| In your `langgraph.json`, add the path to your auth file: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Then, in your auth.ts file, add your auth logic: | |
| Then, in your `auth.ts` file, add your auth logic: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| In your langgraph.json, add the path to your auth file: | |
| In your `langgraph.json`, add the path to your auth file: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Then, in your auth.ts file, add your auth logic: | |
| Then, in your `auth.ts` file, add your auth logic: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
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-passthroughusage flow:asynchronous-authorization/langchain-next-jsauthenticate-users/langchain-next-jsauthorization-for-rag/langchain-next-jscall-apis-on-users-behalf/others-apicall-apis-on-users-behalf/yours-apiTesting
Checklist