I've handled tons of medieval Scottish royal charters, official royal documents the kings issued, dating from the 1350s to the 1450s, which use the Latin, "dei gracia rex scottorum" - translating to "by the grace of god King of the Scots". No one can say what the kings and scribes believed privately, but the divine claim to rule was absolutely a bog standard, boilerplate part of the royal propaganda of that time period in Scotland.
My studies dealt with the practical side of politics and power - focussing more on what (mostly) men did with the power they had. There's no doubt someone with a specialty in medieval political theory who can jump in here and expand quite a bit on how (I expect mostly) churchmen theorized about how government and kings ought to function, and from where their power originated.