Id say it would have to be at the border for a stamp in your passport. They don't always stop cars and busses coming through.
You can get an Andorra stamp at the border. I got one last summer when entering by car from Spain. I think they have them entering from France too but haven't seen that myself. I asked the Andorra police officer. He actually left his position and went into his office to stamp our family's all four passports. Really nice and for free - but they only do it if you ask for it. The stamp doesn't have any date and doesn't say entry or exit. So it doesn't prove when you were there, but it's nice anyway for us passport stamp collectors and tourists. They only do it at the border, not at any tourism office.
Not possible to get a stamp at the tourist offices in Andorra La Vella (nevertheless they offer some nice and affordable souvenirs). I got a stamp easily at the border when I left to France (inside the building at the desk). Even the bus driver from Andbus was willing to stop for a couple of minutes so I could get my stamp :)
Here are the official rules:
Officially you need either a passport or an identity card depending on your citizenship. They don't actually check many passports at the border but can do whenever they like.