I remember hearing about some people thinking Ash didn't earn some or even any of his gym badges in Kanto, something that even gets brought up in the anime with Misty saying that he only got his first two because Brock and her sisters felt sorry for him (which is a complete lie)
To me Ash did earn these badges because the whole point is proving yourself as a Trainer, usually by defeating them in battle, though in Ash's case he proved himself by other means
With Brock he didn't feel right taking advantage of Onix's weakness (which also means that Ash felt sorry for him not the other way around)
With Misty he saved the gym from Team Rocket and probably would've won as he had two Pokemon left while Misty only had one, one already weakened earlier in the fight (plus he was suffering from a massive handicap by not having Pikachu too!)
Lt Surge he won against Raichu (was his first "real" match against a gym leader too)
Erika, he risked his life saving her Gloom (if Erika had decided "You still don't get a badge because you still didn't beat me" after that...)
Sabrina... I won't defend that one but I won't argue if others do
Koga and Blaine, I actually don't remember the details (I had the others on VHS or saw them as a kid) but I'm pretty sure they were normal battles
And then the last one was against Team Rocket albeit with their boss' Pokemon (and a setup that involved zapping them every time their Pokemon took damage), so that's a weird case
But what are your thoughts on the matter?