Server refactor for oAuth