libevent based oauth2, oauth2 refactoring