You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// In v4, the AUTH0_SCOPE and AUTH0_AUDIENCE environment variables are no longer automatically picked up by the SDK.
101
+
// Instead, we need to provide the values explicitly.
102
+
scope: process.env.AUTH0_SCOPE,
103
+
audience: process.env.AUTH0_AUDIENCE,
104
+
},
105
+
});
106
+
107
+
// Get the Access token from Auth0 session
108
+
exportconst getAccessToken =async () => {
109
+
const tokenResult =awaitauth0.getAccessToken();
110
+
111
+
if(!tokenResult||!tokenResult.token) {
112
+
thrownewError("No access token found in Auth0 session");
113
+
}
114
+
115
+
returntokenResult.token;
101
116
};
102
117
```
103
118
104
-
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.
119
+
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.
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.
141
+
</Info>
142
+
In your `langgraph.json`, add the path to your auth file:
Call the tool from your AI agent to get data from documents. First, update the `/src/app/api/chat/[..._path]/route.ts` file with the following code to pass the user credentials to your agent:
// In v4, the AUTH0_SCOPE and AUTH0_AUDIENCE environment variables are no longer automatically picked up by the SDK.
160
+
// Instead, we need to provide the values explicitly.
161
+
scope: process.env.AUTH0_SCOPE,
162
+
audience: process.env.AUTH0_AUDIENCE,
163
+
},
164
+
});
165
+
166
+
// Get the Access token from Auth0 session
167
+
exportconst getAccessToken =async () => {
168
+
const tokenResult =awaitauth0.getAccessToken();
169
+
170
+
if(!tokenResult||!tokenResult.token) {
171
+
thrownewError("No access token found in Auth0 session");
172
+
}
173
+
174
+
returntokenResult.token;
175
+
};
176
+
150
177
exportconst getUser =async () => {
151
178
const session =awaitauth0.getSession();
152
179
returnsession?.user;
153
180
};
154
181
```
155
182
156
-
Now, update the `/src/lib/agent.ts` file with the following code to add the tool to your agent:
183
+
### Add Custom Authentication
184
+
<Info>
185
+
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.
186
+
</Info>
187
+
In your `langgraph.json`, add the path to your auth file:
0 commit comments