If you live in a state that has legalized the medical use of marijuana, there is no requirement under any of the state laws that you be a U.S. citizen to use medical marijuana. Some states require you to register with a government agency in order to take advantage of the law and require a state-issued identification card to prove you live there.
If you are not in the United States legally, you could have difficulty obtaining such identification. If you are a lawful permanent resident of the U.S. (a "green card" holder) and you don't yet have identification like a driver's license or state ID card, however, you can apply for one by showing your green card. The question is, should you do so, and what will happen if federal authorities find out? As discussed below, you:
Just because your state's law allows you to use medical marijuana does not mean there is no risk to your lawful permanent resident status if you do so. This is because your immigration status is a federal matter, governed by federal law, which makes any marijuana use illegal.
So, even though your state might not convict you for using marijuana for medical purposes, the federal government can, and sometimes does. (See USCIS Policy Manual, Chapter 5.)
Green card holders convicted of a violation of a federal law relating to marijuana (other than a single offense involving possession for their own use of 30 grams or less) are deportable. You're also deportable if you are a "drug abuser or addict." It's possible that the U.S. government will allege that your medical use of marijuana constitutes abuse or addiction.
Also, conviction of certain crimes involving "moral turpitude" can get you deported. That's a fuzzy term under U.S. immigration law, and you can't be sure what a court will say. However, possession of marijuana for personal use is likely not a crime involving moral turpitude. Growing marijuana for a medical purpose likely wouldn't be either. For more, see What's a Crime of Moral Turpitude According to U.S. Immigration Law?
Even if U.S. immigration authorities don't take immediate steps to deport you, they will raise questions about drug use if and when you apply for U.S. citizenship, and USCIS could deny your application or take steps to deport you at that time.
If you're a green card holder who wants to travel outside the U.S., your medical use of marijuana could cause you problems getting back in and staying in the United States. This is because the U.S. Customs and Border Protection officer at the border could treat you as an "arriving alien" who must be "admissible" to the United States.
As a green card holder, you're not always considered an "arriving alien" when returning after foreign travel, but you are an inadmissible arriving alien if you have been convicted of a federal crime relating to marijuana—or even if you admit having used marijuana, no matter how legal it was in your state. (Carrying a medical marijuana card in your wallet is a sure tipoff.)
You also have to be concerned with anything you've done that would give the government reason to believe you're a marijuana "trafficker," or dealer. This might include admitting that you work for a legal dispensary or grower.
If the U.S. government determines that you are an inadmissible arriving alien, you will most likely be let back into the U.S. temporarily, and deportation (removal) proceedings will be started against you. You might be eligible for a "waiver" of your inadmissibility if your crime is a single offense of simple possession of 30 grams or less of marijuana.
Talk to an experienced attorney for a full analysis of your situation, particularly if you plan to travel outside the United States. And if you are arrested and placed into immigration court proceedings, getting an attorney's help will be crucial.