rewrite implementation of oauth login