# format_login_failure

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/mcp_auth/format_login_failure)

Return a token-safe single-line summary of an OAuth-login exception.

OAuth handshakes commonly surface as `ExceptionGroup` (anyio task
groups) or as MCP-SDK errors whose `args`/`repr` may include an
`OAuthToken`. Never call `str()`/`repr()` on the raw exception for
display or logging — instead, prefer a known-safe nested
`MCPReauthRequiredError` message, fall back to the messages of our
own loopback-related exception types, and degrade to a class-name
chain for anything else.

## Signature

```python
format_login_failure(
    exc: BaseException,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `exc` | `BaseException` | Yes | Root exception caught from the login worker. |

## Returns

`str`

A user-displayable string that is safe to log and to render.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/0412009c5441bef8d75a427e1da8909e33ab5b56/libs/code/deepagents_code/mcp_auth.py#L1440)