Both are served by the BART, as well as have taxi/Uber/Lyft pick up areas. Depending on your arrival time, the BART may be the fastest way to go, especially if flying into Oakland as rush hour traffic across the Oakland Bay Bridge can cause significant delays.
BART requires a ticket to enter and leave the system -- make sure to hold onto the ticket. The vending machines take cash or credit. The fares to downtown San Francisco are:
Both airports have pickup areas for the taxi/Uber/Lyft. From San Francisco Airport: