Updated oauth with better error handling.