In the effective background field theory of string theory, the Green-Schwarz
anomaly cancellation mechanism plays a key role. Here we reinterpret it and its
magnetic dual version in terms of differential twisted String- and differential
twisted Fivebrane-structures that generalize the notion of Spin-structures and
Spin-lifting gerbes and their differential refinement to smooth
Spin-connections. We show that all these structures can be encoded in terms of
nonabelian cohomology and twisted nonabelian cohomology and differential
twisted nonabelian cohomology, extending the differential generalized abelian
cohomology as developed by Hopkins and Singer and shown by Freed to formalize
the global description of anomaly cancellation problems in higher gauge
theories arising in string theory. We demonstrate that the Green-Schwarz
mechanism for the H3-field, as well as its magnetic dual version for the
H7-field define cocycles in differential twisted nonabelian cohomology that may
be called, respectively, differential twisted Spin(n)-, String(n)- and
Fivebrane(n)-structures on target space, where the twist in each case is
provided by the obstruction to lifting the classifying map of the gauge bundle
through a higher connected cover of U(n) or O(n). We work out the (nonabelian)
L-infinity algebra (L-infinity algebroid) valued differential form data
provided by the differential refinements of these twisted cocycles and
demonstrate that this reproduces locally the differential form data with the
twisted Bianchi identities as known from the string theory literature. The
treatment for M-theory leads to new models for the C-field and its dual in
differential nonabelian cohomology.