refactoring of oauth2 controller