This is a very common question and not as straight forward as you might think.
The answer is yes you can smoke marijuana in your building unless your landlord specifies otherwise. If your landlord specifies otherwise, then no you may not. He or she has the right under the federal Fair Housing Act to deny your smoking within his building. Although it is legal in CA to obtain medical marijuana with a doctor’s recommendation, the federal Fair Housing Act operates under federal jurisdiction, and as we know, cannabis is not legal on the federal level. From what I understand, it is possible to be evicted for smoking marijuana in an apartment, depending on the rules of your building or how your landlord might react. Many now write marijuana use clauses into their leases, so it is important to check! This is similar to how landlords write in clauses regarding cigarette and cigar smoking.
My suggestion to you is to be fair to your neighbors and those around you and smoke outside away from the building. Many neighbors can be negatively impacted by you smoking in and around them depending on your frequency which might lead them to complain which may put you in a precarious situation.
Hope this helps!