auth.py
 1  from typing import Any, Type
 2  
 3  from fastapi import status
 4  
 5  from .api_exception import APIException
 6  from ..utils.docs import responses
 7  
 8  
 9  class InvalidTokenError(APIException):
10      status_code = status.HTTP_401_UNAUTHORIZED
11      detail = "Invalid token"
12      description = "This access token is invalid or the session has expired."
13  
14  
15  def internal_responses(default: type, *args: Type[APIException]) -> dict[int | str, dict[str, Any]]:
16      """api responses for admin_auth dependency"""
17  
18      return responses(default, *args, InvalidTokenError)