Refactor to use oauth2 "Authorization Code" grant type