Adapted to new koauth library. Compiles, not run. Rewritten from beginning.