You get a CD key by buying the game. There's no legitimate way around that — the key comes with your purchase, whether that's a retail copy or a digital one from a storefront.
If you've already bought it and lost the key, the publisher's or store's support channel is the route to recovering it, and you'll need proof of purchase.