If you're at an afterwork with a Swede and they return from the bar telling you, often with thinly veiled pride, that they had to show the bartender their leg to buy a pint: fear not, it's not that kind of pub.
Leg is short for legitimation and both words are used when in English you would normally refer to your ID or your identification document (although the word legitimation itself does also exist in English).
It comes from the Medieval Latin legitimationem, from the verb legitimare which essentially means 'make lawful' or 'declare to be lawful'. English speakers may recognize this more from the word 'legitimate' or 'legitimize'.
In Swedish the short form leg (alternative spelling: legg) is becoming increasingly common, but the longer legitimation has not yet fallen out of use enough to be seen as outdated by most people. Perhaps slightly confusingly, the two words take different articles: it's ett leg but en legitimation.
The word legitimation is also used to explain that someone is allowed to carry out certain professional duties, for example like a certified or licensed doctor (legitimerad läkare or läkarlegitimation).
The Swedish word for 'leg' by the way (as in the limbs connected to your feet), is ben.
Personnummer och legitimation, tack
Personal number and ID, please
Jag var tvungen att visa leg på Systembolaget
I had to show my ID at the state monopoly liquor store