Refactor OAuth2