Refactoring oauth