Measurements of the Higgs boson production cross sections with the Higgs boson decaying into a pair of photons are reported. Events with two photons are selected from a sample of proton-proton collisions at a center-of-mass energy \sqrt{s}=13~\mathrm{TeV} collected by the CMS detector at the LHC in 2016 and 2017, corresponding to an integrated luminosity of 77.4~\mathrm{fb}^{-1}. Cross sections for gluon fusion and vector boson fusion production, normalized to the corresponding standard model predictions, are measured to be and , respectively. These production modes are further measured in kinematic regions within the simplified template cross section framework. All results are found to be in agreement with the standard model expectations.