import os from fastapi import Depends from supabase import create_client from core import logging as logger from core.utils.error_handling import create_error_response, raise_http_exception from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer from dotenv import load_dotenv load_dotenv() security = HTTPBearer() supabase_client = create_client( os.getenv("SUPABASE_URL"), os.getenv("SUPABASE_KEY") ) async def access_check_bearer(credentials: HTTPAuthorizationCredentials = Depends(security)): access_token = credentials.credentials try: supabase_client.auth.get_user(access_token) except Exception as e: logger.info(f">>> Invalid access token {e}<<<") raise_http_exception(code=401, message="Invalid Access Token", details=[ {"info": "Invalid access token or access token expired please login again"}])