It's called a Therapeutic Use Exemption. Basically if you get a doctor's note saying they prescribe you a banned substance to treat a condition or illness you have, then you won't be banned for doping.
This obviously gets abused a lot. The most notorious example was with Lance Armstrong in 2001. He tested positive for EPO at the Tour of Switzerland. But his team, US Postal Service, covered it up. They faked a TUE certificate and even back-dated it on the paperwork, so it said that he started taking treatment months before the race started. And to sweeten the deal he threw in a $125,000 "donation" for anti-doping research.
That's what you have to do to get away with it. You need a doctor who's willing to play ball, you need money for a bribe. But most of all, you need a plausible illness for which the banned substance can be prescribed by a doctor. Richardson has none of these things. To be prescribed cannabis, don't you need to have cancer or something? Some sort of terminal illness, or at least a chronic illness. It's not a prescription you could ever justify for an athlete. How can an athlete undergoing chemotherapy compete.