refactor of Oauth2 library