|
6 | 6 | """ |
7 | 7 |
|
8 | 8 | import logging |
9 | | -from collections.abc import Awaitable, Callable |
| 9 | +from typing import Any |
10 | 10 |
|
11 | 11 | import httpx |
12 | 12 | from pydantic import BaseModel, Field |
@@ -166,8 +166,8 @@ def __init__( |
166 | 166 | storage: TokenStorage, |
167 | 167 | idp_token_endpoint: str, |
168 | 168 | token_exchange_params: TokenExchangeParameters, |
169 | | - redirect_handler: Callable[[str], Awaitable[None]] | None = None, |
170 | | - callback_handler: Callable[[], Awaitable[tuple[str, str | None]]] | None = None, |
| 169 | + redirect_handler: Any = None, |
| 170 | + callback_handler: Any = None, |
171 | 171 | timeout: float = 300.0, |
172 | 172 | ) -> None: |
173 | 173 | """ |
@@ -241,11 +241,11 @@ async def exchange_token_for_id_jag( |
241 | 241 | ) |
242 | 242 |
|
243 | 243 | if response.status_code != 200: |
244 | | - error_data: dict[str, object] = ( |
| 244 | + error_data: dict[str, str] = ( |
245 | 245 | response.json() if response.headers.get("content-type", "").startswith("application/json") else {} |
246 | 246 | ) |
247 | | - error = str(error_data.get("error", "unknown_error")) |
248 | | - error_description = str(error_data.get("error_description", "Token exchange failed")) |
| 247 | + error: str = error_data.get("error", "unknown_error") |
| 248 | + error_description: str = error_data.get("error_description", "Token exchange failed") |
249 | 249 | raise OAuthTokenError(f"Token exchange failed: {error} - {error_description}") |
250 | 250 |
|
251 | 251 | # Parse response |
@@ -312,11 +312,11 @@ async def exchange_id_jag_for_access_token( |
312 | 312 | ) |
313 | 313 |
|
314 | 314 | if response.status_code != 200: |
315 | | - error_data: dict[str, object] = ( |
| 315 | + error_data: dict[str, str] = ( |
316 | 316 | response.json() if response.headers.get("content-type", "").startswith("application/json") else {} |
317 | 317 | ) |
318 | | - error = str(error_data.get("error", "unknown_error")) |
319 | | - error_description = str(error_data.get("error_description", "JWT bearer grant failed")) |
| 318 | + error: str = error_data.get("error", "unknown_error") |
| 319 | + error_description: str = error_data.get("error_description", "JWT bearer grant failed") |
320 | 320 | raise OAuthTokenError(f"JWT bearer grant failed: {error} - {error_description}") |
321 | 321 |
|
322 | 322 | # Parse OAuth token response |
|
0 commit comments