Maybe I didn’t understand your question after all, I thought it was about how to pass authorization information for LiveSocket. So if I now understood correctly your problem was in it’s simplicity, how to pass data from router to LiveView during initial request? There is an example how to do that here in LiveView docs Referencing parent assigns
controller
conn
|> assign(:current_user, user)
|> LiveView.Controller.live_render(MyLive, session: %{“user_id” => user.id})LiveView mount
def mount(_params, %{“user_id” => user_id}, socket) do
{:ok, assign_new(socket, :current_user, fn → Accounts.get_user!(user_id) end)}
end
There is also previous thread talking about this LiveView lifecycle hook with access to Conn? but the link provided there by José doesn’t work anymore, this is the correct link Security considerations of the LiveView model — Phoenix LiveView v0.17.5