All residents are granted a temporary limited license under their training program. This allows you to prescribe drugs and perform as a physician within the the constraints of the supervised structure of your training.
You have to pass part 3 of USMLE and then apply to the state board for your permanent license. Usually this happens during or after your second year. At this point you may then moonlight in EDs, etc., function independently and receive compensation for your work.