---
title: exceptions
sidebarTitle: exceptions
---

# `keycardai.oauth.exceptions`


OAuth 2.0 exception hierarchy with retriable classification.

This module provides structured exception classes with deterministic retry guidance
for OAuth 2.0 operations as defined across multiple RFCs.

References:
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 8693: OAuth 2.0 Token Exchange
- RFC 7662: OAuth 2.0 Token Introspection
- RFC 7009: OAuth 2.0 Token Revocation


## Classes

### `OAuthError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L16" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Base class for all OAuth 2.0 errors.


### `OAuthHttpError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L25" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


HTTP-level errors with retry guidance.

Raised for HTTP status codes indicating server or client errors.
Includes deterministic retriability classification.


### `OAuthProtocolError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L67" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


RFC 6749 error responses from OAuth servers.

Represents structured error responses as defined in OAuth 2.0 specifications.
Protocol errors are never retriable as they indicate client-side issues.


### `NetworkError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L101" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Transport/network failures with retry guidance.

Covers connection failures, timeouts, and other network-level issues.


### `ConfigError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L129" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Client configuration errors.

Raised when client is misconfigured (missing endpoints, invalid parameters, etc.).
These are never retriable as they require code changes.


### `AuthenticationError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L140" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Authentication failures with OAuth 2.0 servers.

Raised when client authentication fails, typically due to invalid
credentials or authentication method issues.


### `TokenExchangeError` <sup><a href="https://github.com/keycardai/python-sdk/blob/main/src/keycardai/oauth/exceptions.py#L151" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


OAuth 2.0 Token Exchange specific errors (RFC 8693).

Raised for token exchange protocol violations and error responses.
Inherits from OAuthProtocolError with token exchange semantics.

