The Court of Appeal has ruled a 40-year licence granted by Hauraki District Council to Oceana Gold for mining structures was unlawful.