Add check if OAuth code is missing to prevent 500 error