The requirements for the secret ending differ depending on which Kingdom Hearts you're playing.
In Kingdom Hearts II, you'll need to fully complete Jiminy's Journal, filling in every entry to reveal the hidden finale. In the original Kingdom Hearts, the task is to track down all 101 Dalmatians that have been scattered across the various worlds.
Either way, it takes some thorough exploring, but the payoff is well worth the effort for dedicated fans.