I traveled to quite a lot of places and I think so far never payed a bribe. Maybe I once did for airport processing in Jordan or maybe not - I'm not completely sure if the fee was legit.
Generally many of the tips mentioned here so far don't work well form me.
I'm a tourist. I look like being out of place. That start's with my physical appearance. Maybe I can go native in Sweden, Iceland or Scotland but if you are taller and less pigmented than nearly everybody in the world I't hard to blend in.
Also I'm there not to look suave, know-it-all and know what I'm doing. So I stop for the details. I take pictures. I wonder at the exotic food. I don't know how to cross the street, etc.
Also I'm very obviously just passing through. I obviously don't know important local people. I'm alone and vulnerable like travelers always have been.
So how to go about bribes?
First and foremost: try hard to stay on the right side of the law. You are a guest and are obliged to follow the local customs and rules even when you don't like them. If they want you to stop at every zebra crossing do so. Even when the locals do not do so. Have spare bulbs, warning vests etc. with you as required. Check that your vehicle lights are in order, etc. Regarding driving it is often wise to follow a local truck. These are professionals and know very well what is accepted by the police. Usually.
If you think smoking pot should be legal protest the laws by breaking them at home. Don't try it aboard. Remember, you are a traveler and vulnerable.
Approach officials with respect and without fear. All in all people in police forces are tending to lean to law, order and an certain standard of fairness. Even when they are corrupt. They expect to be respected so give them that feeling so they do not feel the need to teach you a lesson.
Since you did not really seriously break any law we are not talking about bribes here. You are not paying to get any favour or to have the official look away. We alle looking at the request for a "Bakschisch", "Souvenier", "Present" here.
The official is just curious about you and checking if he can extract some money from you. So when he walks away from you best thing he says "that didn't pay but was interesting and fun."
You probably should see police checks as the trade of time versus money. And as a game.
So have lot's of time and humour. Show clearly that you are willing to go into every detail for hours. I never had resort so far to getting out camping chairs and started boiling tea. But I'm told this works nicely.
Be interested in what you had done wrong. Perhaps you really have done something wrong. Explain why you did as you did and why you are convinced that this was legal. Explain (and we get back to authority there) that you informed yourself about that rule before starting the trip and got the information (e.g. from the embassy, a touring club) that it was ok to do so.
Be friendly. Laughs a lot. Talk long and extensive about your trip so far and where you willing to go and how wonderful the country is. (Maybe tie in that people at your next destination awaiting you and know where you are.) Get to the point the official want to get rid of you instead the other way around.
Ask a lot for help how to do things better. To stay on the right side of the law. What to see. How to cross the next river. How to avoid Crime. Where to eat. etc.
Show the official that you think this is your lucky day to have met this competent, important and friendly policeman-expert about just everything.
If he asks for money an it sounds like an official fine ask for a receipt. Ask to be taken to the police station and pay it there. Ask for the receipt to be signed by his boss. Ask for an translator. Ask to take pictures of all documents involved. Ask for the embassy. But better don't get to that point at all.
If somebody asks for money and it can be seen as corruption act like it was a joke. Corruption is illegal in all countries. Play like the official is teasing you. Or even testing you if you are corrupt to fine you for it.
Show that paying bribes would also be highly illegal under your own countries rules. "verboten" is a word understood worldwide.
And always keep high spirit an take it as a game. You could probably afford the bribe if it came to that.
Worked for me every time. Occasionally they get rude to get rid of me.
When the Ukrainan customs officials called the police I knew I was in deep trouble. Watch out for those signs. Usually corruption is a 1:1 business. Thats why asking for the boss can defend against most corruption attempts. That different branches of government collaborate on minor corruption is unusual.
Than again it's time to think about what will be the easiest thing for the officials to get rid of the problem that is you. In my case it was deporting me 100m eastern direction to Poland - exactly where I wanted to go.