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
This section describes how to authenticate the ToolboxClient itself when
227
+
connecting to a Toolbox server instance that requires authentication. This is
228
+
crucial for securing your Toolbox server endpoint, especially when deployed on
229
+
platforms like Cloud Run, GKE, or any environment where unauthenticated access is restricted.
230
+
231
+
This client-to-server authentication ensures that the Toolbox server can verify the identity of the client making the request before any tool is loaded or called. It is different from [Authenticating Tools](#authenticating-tools), which deals with providing credentials for specific tools within an already connected Toolbox session.
232
+
233
+
### When is Client-to-Server Authentication Needed?
234
+
You'll need this type of authentication if your Toolbox server is configured to deny unauthenticated requests. For example:
235
+
236
+
- Your Toolbox server is deployed on Cloud Run and configured to "Require authentication."
237
+
- Your server is behind an Identity-Aware Proxy (IAP) or a similar authentication layer.
238
+
- You have custom authentication middleware on your self-hosted Toolbox server.
239
+
240
+
Without proper client authentication in these scenarios, attempts to connect or
241
+
make calls (like `load_tool`) will likely fail with `Unauthorized` errors.
242
+
243
+
### How it works
244
+
245
+
The `ToolboxClient` (and `ToolboxSyncClient`) allows you to specify functions (or coroutines for the async client) that dynamically generate HTTP headers for every request sent to the Toolbox server. The most common use case is to add an Authorization header with a bearer token (e.g., a Google ID token).
246
+
247
+
These header-generating functions are called just before each request, ensuring
248
+
that fresh credentials or header values can be used.
249
+
250
+
### Configuration
251
+
252
+
You can configure these dynamic headers in two ways:
1. **Configure Permissions**: [Grant](https://cloud.google.com/run/docs/securing/managing-access#service-add-principals) the `roles/run.invoker` IAM role on the Cloud
280
+
Run service to the principal. This could be your `user account email`or a
0 commit comments