The furthest this quote can be traced back is to the 1935 book The Treasure of the Sierra Madre, but the snowclone entered the wider world via 1974’s Blazing Saddles, which in turn is a reference to the 1948 Humphrey Bogart film (based on the book) The Treasure of the Sierra Madre. Badges show up in all three quotes:
Badges, to god-damned hell with badges! We have no badges. In fact, we don’t need badges. I don’t have to show you any stinking badges…
Badges? We ain’t got no badges. We don’t need no badges. I don’t have to show you any stinking badges.
Badges? We don’t need no stinking badges.
In subsequent movie and TV references, X is most often “badges,” but usage elsewhere reveals a variety of plural and singular nouns in the X slot: login, cookies, recount, silos.
This snowclone is used when the writer wants to express contempt or mock contempt for someone asking for X.
Pronunciation of “stinking” also seems to be an important element of this snowclone. The original speaker being Mexican, and thus apparently a non-native speaker of English, was a salient piece of information to snowcloners, and again the relationship to the original quote is strengthened by use of that pronunciation. That or they equate his non-standard English with the casualness of conversation they want the snowclone to carry. So [as Arnold Zwicky noted in comments] steenkin, stinkin, and stinking are all possible variants.
[Edited to add quotes from all three sources, after David Craig provided a link to the original movie vector of the snowclone. Thanks, David!]
[Edit 2: I forgot to add the link for a much earlier and better discussion of this snowclone, at Subjunctivitis.]