The attention paid to different auth protocols here is great -- this should be refactored out of this method to make it reusable. It's actually applicable outside of this gem.