Communicate state between, e.g., FastAPI and embedded Panel app (Bokeh server)


I have a Panel app that I embedded inside of a FastAPI application. This works well so far.

I have implemented my own authorization and created a user object which I would now like to pass down to the Panel app. The official OAuth providers apparently set pn.state.user and pn.state.user_info, however, they appear immutable to me.

Is the best way for me to do so via the pn.state.cache or is there a better way that I’m missing?

Thank you for your help.

Hi @Midnighter

What do you mean by “appear immutable to me”?

I couldn’t find a description in the docs on how to set the user.

import panel as pn

pn.state.user = {"name": "username"}
AttributeError: property 'user' of '_state' object has no setter