Update API Token using function called from handle_event

The Task.await below will get the value returned by this code, which right now is the return value of IO.puts. You likely want:

          _ ->
            IO.puts("TOKEN RECEIVED")
            {:ok, token}

That way the Task.await receives the token.

I’d recommend keeping the “get a token” and “put that token into assigns” parts separate; having a side-effecting function named get_* seems odd. So you’d store the token into socket wherever is calling get_token.


Mostly-unrelated question: what’s the purpose of the Task.async followed immediately by a Task.await? Is it for the 5s timeout?