Refactored redirects to allow authentication from Pebble