Refactor oauth