Nearly every photographer that comments on this issue says it is OK if you do it very briefly such
as when you are taking a scenery photo and the sun is in the picture. The argument for it not being safe
is that some of the more recent smartphones use larger and faster lenses (f/1.7 to f/2.0) to get better
resolution, and that can be a problem.
Most digital cameras have an Auto mode in which they will automatically reduce the exposure
speed and increase the f/stop to take the photo, and this will not harm the camera
A camera isn’t your eyes, you could point it at the sun all day.
Source: NASA(PDF warning)