Reconstruction of the solar coronal magnetic field in spherical geometry