# SandboxTokenVerifier

> **Class** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/sandbox/_verify/SandboxTokenVerifier)

Verifies tokens LangSmith signs for code running in or behind a sandbox.

Keys are fetched from LangSmith's JWKS endpoint and cached.

## Signature

```python
SandboxTokenVerifier(
    self,
    *,
    api_url: Optional[str] = None,
    jwks_url: Optional[str] = None,
    timeout: float = 10.0,
    allow_insecure_jwks: bool = False,
)
```

## Description

**Example:**

verifier = SandboxTokenVerifier()

# In an app served from a LangSmith-login service URL:
user = verifier.verify_user_token(
    request.headers[USER_TOKEN_HEADER], audience=request.headers["Host"]
)

# In a proxy callback endpoint:
callback = verifier.verify_callback(
    body=await request.body(),
    signature=request.headers[CALLBACK_SIGNATURE_HEADER],
    aud="https://example.com/sandbox-callback",
)

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `api_url` | `Optional[str]` | No | LangSmith API URL whose origin serves the JWKS. Defaults to LANGSMITH_ENDPOINT. (default: `None`) |
| `jwks_url` | `Optional[str]` | No | Full JWKS URL; overrides ``api_url``. (default: `None`) |
| `timeout` | `float` | No | HTTP timeout in seconds for fetching the JWKS. (default: `10.0`) |
| `allow_insecure_jwks` | `bool` | No | Allow fetching the JWKS over plain HTTP from a non-loopback host. Anyone who can tamper with that traffic can forge tokens this verifier accepts. (default: `False`) |

## Constructors

```python
__init__(
    self,
    *,
    api_url: Optional[str] = None,
    jwks_url: Optional[str] = None,
    timeout: float = 10.0,
    allow_insecure_jwks: bool = False,
) -> None
```

| Name | Type |
|------|------|
| `api_url` | `Optional[str]` |
| `jwks_url` | `Optional[str]` |
| `timeout` | `float` |
| `allow_insecure_jwks` | `bool` |


## Methods

- [`verify_user_token()`](https://reference.langchain.com/python/langsmith/sandbox/_verify/SandboxTokenVerifier/verify_user_token)
- [`averify_user_token()`](https://reference.langchain.com/python/langsmith/sandbox/_verify/SandboxTokenVerifier/averify_user_token)
- [`verify_callback()`](https://reference.langchain.com/python/langsmith/sandbox/_verify/SandboxTokenVerifier/verify_callback)
- [`averify_callback()`](https://reference.langchain.com/python/langsmith/sandbox/_verify/SandboxTokenVerifier/averify_callback)

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/19d52419f47c93ca2c57a0d51c58d255f5949092/python/langsmith/sandbox/_verify.py#L154)