Talbot-Lau grating interferometry enables the use of polychromatic x-ray sources, extending the range of potential applications amenable to phase contrast imaging. However, these sources introduce beam hardening effects not only from the samples but also from the gratings. As a result, grating inhomogeneities due to manufacturing imperfections can cause spectral nonuniformity artifacts when used with polychromatic sources. Consequently, the different energy dependencies of absorption, phase, and visibility contrasts impose challenges that so far have limited the achievable image quality. The purpose of this work was to develop and validate a correction strategy for grating-based x-ray imaging that accounts for beam hardening generated from both the imaged object and the gratings. The proposed two-variable polynomial expansion strategy was inspired by work performed to address beam hardening from a primary modulator. To account for the multicontrast nature of grating interferometry, this approach was extended to each contrast to obtain three sets of correction coefficients, which were determined empirically from a calibration scan. The method's feasibility was demonstrated using a tabletop Talbot-Lau grating interferometer micro-computed tomography (CT) system using CT acquisitions of a water sample and a silicon sample, representing low and high atomic number materials. Spectral artifacts such as cupping and ring artifacts were quantified using mean squared error (MSE) from the beam-hardening-free target image and standard deviation within a reconstructed image of the sample. Finally, the model developed using the water sample was applied to a fixated murine lung sample to demonstrate robustness for similar materials. The water sample's absorption CT image was most impacted by spectral artifacts, but following correction to decrease ring artifacts, an 80% reduction in MSE and 57% reduction in standard deviation was observed. The silicon sample created severe artifacts in all contrasts, but following correction, MSE was reduced by 94% in absorption, 96% in phase, and 90% in visibility images. These improvements were due to the removal of ring artifacts for all contrasts and reduced cupping in absorption and phase images and reduced capping in visibility images. When the water calibration coefficients were applied to the lung sample, ring artifacts most prominent in the absorption contrast were eliminated. The described method, which was developed to remove artifacts in absorption, phase, and normalized visibility micro-CT images due to beam hardening in the system gratings and imaged object, reduced the MSE by up to 96%. The method depends on calibrations that can be performed on any system and does not require detailed knowledge of the x-ray spectrum, detector energy response, grating attenuation properties and imperfections, or the geometry and composition of the imaged object.