Refactored handleOAuthURL function with proper variable types