refactoring oauth2 module