copy some auth stuff from the demo