Refactor an Oauth controller

Move common code to helper