Refactor github auth code