David:
Most important are your eyes! Like Toverman says: Protect them at all costs! Sunglasses won't solve the problem, but they will give minimal protection, and will minimize the bright spots you see afterwards.
Next, comes your camera. A lens is nothing more than a complicated magnifying glass, and you remember all the neat tricks we used to do with them! Crispy ants, setting things on fire...
In the stone ages, many holes were burned through the fabric of focal plane shutters on rangefinder cameras (look under Photography, Archaic)

by focusing on infinity, and pointing the camera at the sun.
I called Nikon, and the tech told me that potential damage to shutters and sensors is not likely, because the mirror is interposed between the shutter and sensor except for the short time of the exposure. Nikon sensors "may" develop an afterimage, so it is best to wait "a few seconds" between exposures, sez he.
Try this: If you want the sun in your photo, and there is no reason not to include it, BE QUICK! In very short views thru the viewfinder, choose your composition. SHORT!
The best time is in the early morning, or late afternoon, when the sun is shining through a greater amount of atmosphere, somewhat lessening its effect, and lighting is usually more dramatic.
Manual focus at infinity, then if you want the sky to be properly exposed, pick a spot of sky to the side of the sun, lock exposure, then quickly return to your chosen composition, and take the picture. Quickly point the camera away from the sun. Repeat as necessary. A tripod is a goodness, for those
of us'ns who don't have some sort of image stabilization.
To answer your original question: As short as possible.