WIP: Fix OAuth error handling

Work in progress, needs more tests!