Coverage for polar/oauth2/exception_handlers.py: 45%
9 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
1import json 1a
3from authlib.oauth2 import OAuth2Error 1a
4from fastapi import Request, Response 1a
7async def oauth2_error_exception_handler( 1a
8 request: Request, exc: OAuth2Error
9) -> Response:
10 status_code, body, headers = exc()
11 if isinstance(body, dict):
12 body = json.dumps(body)
13 return Response(body, status_code=status_code, headers={k: v for k, v in headers})
16__all__ = ["oauth2_error_exception_handler", "OAuth2Error"] 1a