INNER CODE UNIT · Python

verify_token

agentscope-ai/agentscope-runtime · src/agentscope_runtime/sandbox/manager/server/app.py:116

def verify_token(
    credentials: HTTPAuthorizationCredentials = Depends(security),
):
    """Verify Bearer token"""
    settings = get_settings()

    if not hasattr(settings, "BEARER_TOKEN") or not settings.BEARER_TOKEN:
        logger.warning("BEARER_TOKEN not configured, skipping authentication")
        return credentials

    if credentials is None:
        logger.error("Authentication required but no token provided")
        raise HTTPException(
            status_code=401,
            detail="Authentication required",
            headers={"WWW-Authenticate": "Bearer"},
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…