Authentication with FastAPI

I am trying to implement authentication with Fast API over a panel app, but struggling with a basic concept. I can get the authentication to work, and I can protect a particular endpoint by using a dependency on a function (‘get_current_user_from_token’ in the pseudo code below). For simple cases, I can return an HTML (or JSON) response from the ‘protect’ function. What do I return for a panel app created with add_applications(…)?

Pseudo code:

import panel as pn

from fastapi import FastAPI
from panel.io.fastapi import add_applications
< Other imports >
app = FastAPI()

def create_panel_app():
    <code to create panel object>
    return <some panel object>

add_applications({"/panel_app": create_panel_app}, app=app)

# Only logged in users should be able to access this route.
@app.get("/panel_app")
def protect(request: Request, user: User = Depends(get_current_user_from_token)):
    < Some Code>
   return <Some Object>

Any suggestions would be welcome.
Thanks.