refactor auth function to use request npm package